Commit Diff


commit - 1afd6a68da181e3ea73fb1a8b9163b6e4d0f57b1
commit + 5f285272dff39a7d4b876e094dd60b9afab0f523
blob - 2cd5e293a4b02a748bc51d18db0c5ee2e40a8718
blob + 22d16cbae24715360fe2f536604709b747f652da
--- net.c
+++ net.c
@@ -94,7 +94,7 @@ static void	 close_with_errf(struct req*, const char*,
     __attribute__((format(printf, 2, 3)));
 
 static int	 try_to_connect(struct req *);
-static int	 gemini_parse_reply(struct req *, const char *, size_t);
+static int	 gemini_parse_reply(struct req *, const char *);
 static void	 net_ev(int, int, void *);
 static void	 handle_dispatch_imsg(int, int, void*);
 
@@ -352,15 +352,12 @@ try_to_connect(struct req *req)
 }
 
 static int
-gemini_parse_reply(struct req *req, const char *header, size_t len)
+gemini_parse_reply(struct req *req, const char *header)
 {
 	struct ibuf	*ibuf;
+	size_t		 len;
 	int		 code;
-	const char	*t;
 
-	if (len < 4)
-		return 0;
-
 	if (!isdigit(header[0]) || !isdigit(header[1]))
 		return 0;
 
@@ -368,14 +365,14 @@ gemini_parse_reply(struct req *req, const char *header
 	if (header[2] != ' ')
 		return 0;
 
-	t = header + 3;
-	len = strlen(t) + 1;
+	header += 3;
+	len = strlen(header) + 1;
 
 	if ((ibuf = imsg_create(&iev_ui->ibuf, IMSG_REPLY, req->id, 0,
 	    sizeof(code) + len)) == NULL)
 		die();
 	if (imsg_add(ibuf, &code, sizeof(code)) == -1 ||
-	    imsg_add(ibuf, t, len) == -1)
+	    imsg_add(ibuf, header, len) == -1)
 		die();
 	imsg_close(&iev_ui->ibuf, ibuf);
 	imsg_event_add(iev_ui);
@@ -508,7 +505,7 @@ net_ev(int fd, int ev, void *d)
 			return;
 		}
 		req->state = CONN_BODY;
-		r = gemini_parse_reply(req, header, len);
+		r = gemini_parse_reply(req, header);
 		buf_drain(&req->bio.rbuf, len);
 		if (r == 0) {
 			close_with_err(req, "Malformed gemini reply");