B"H net_io.c: http server: content should be dynamically allocated

This commit is contained in:
hhm 2014-09-17 07:32:34 -04:00
parent df19d51bc6
commit 32fc5fddd0

View file

@ -749,7 +749,7 @@ int handleHTTPRequest(struct client *c, char *p) {
hrp = realpath(HTMLPATH, NULL); hrp = realpath(HTMLPATH, NULL);
hrp = (hrp ? hrp : HTMLPATH); hrp = (hrp ? hrp : HTMLPATH);
clen = -1; clen = -1;
content = "Server error"; content = calloc(1, 1);
if (rp && (!strncmp(hrp, rp, strlen(hrp)))) { if (rp && (!strncmp(hrp, rp, strlen(hrp)))) {
if (stat(getFile, &sbuf) != -1 && (fd = open(getFile, O_RDONLY)) != -1) { if (stat(getFile, &sbuf) != -1 && (fd = open(getFile, O_RDONLY)) != -1) {
content = (char *) malloc(sbuf.st_size); content = (char *) malloc(sbuf.st_size);