From 22c90415bed9a22c57ef11318d6b7e72d6bd3a0c Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Sat, 2 Jul 2016 10:50:55 +0100 Subject: [PATCH] Check we got a full read when serving local files over HTTP. --- net_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net_io.c b/net_io.c index 70e9901..6ecedee 100644 --- a/net_io.c +++ b/net_io.c @@ -1391,7 +1391,7 @@ static int handleHTTPRequest(struct client *c, char *p) { if (!strncmp(hrp, rp, strlen(hrp))) { if (stat(getFile, &sbuf) != -1 && (fd = open(getFile, O_RDONLY)) != -1) { content = (char *) realloc(content, sbuf.st_size); - if (read(fd, content, sbuf.st_size) != -1) { + if (read(fd, content, sbuf.st_size) == sbuf.st_size) { clen = sbuf.st_size; statuscode = 200; statusmsg = "OK";