Merge branch 'realpath-memory-leak'
This commit is contained in:
commit
af957da81c
12
net_io.c
12
net_io.c
|
@ -835,14 +835,16 @@ int handleHTTPRequest(struct client *c, char *p) {
|
||||||
} else {
|
} else {
|
||||||
struct stat sbuf;
|
struct stat sbuf;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
char *rp, *hrp;
|
char rp[PATH_MAX], hrp[PATH_MAX];
|
||||||
|
|
||||||
|
if (!realpath(getFile, rp))
|
||||||
|
rp[0] = 0;
|
||||||
|
if (!realpath(HTMLPATH, hrp))
|
||||||
|
strcpy(hrp, HTMLPATH);
|
||||||
|
|
||||||
rp = realpath(getFile, NULL);
|
|
||||||
hrp = realpath(HTMLPATH, NULL);
|
|
||||||
hrp = (hrp ? hrp : HTMLPATH);
|
|
||||||
clen = -1;
|
clen = -1;
|
||||||
content = strdup("Server error occured");
|
content = strdup("Server error occured");
|
||||||
if (rp && (!strncmp(hrp, rp, strlen(hrp)))) {
|
if (!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 *) realloc(content, sbuf.st_size);
|
content = (char *) realloc(content, sbuf.st_size);
|
||||||
if (read(fd, content, sbuf.st_size) != -1) {
|
if (read(fd, content, sbuf.st_size) != -1) {
|
||||||
|
|
Loading…
Reference in a new issue