diff options
author | 2009-05-12 20:15:11 -0400 | |
---|---|---|
committer | 2009-05-12 20:15:11 -0400 | |
commit | 90d8c8cb498fd7aacd19682d2979186e76805808 (patch) | |
tree | 1608cc110ac8aad6730dbe1e2199d6605483102d /src/c/driver.c | |
parent | 651ce2989ae98565bec96ea92e7c8ec3f1c8ea79 (diff) |
Stop potential buffer overrun of path_copy
Diffstat (limited to 'src/c/driver.c')
-rw-r--r-- | src/c/driver.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/c/driver.c b/src/c/driver.c index 2f84184f..af3e73a3 100644 --- a/src/c/driver.c +++ b/src/c/driver.c @@ -150,6 +150,8 @@ static void *worker(void *data) { uw_context ctx = new_context(); size_t buf_size = 2; char *buf = malloc(buf_size); + size_t path_copy_size = 0; + char *path_copy = malloc(path_copy_size); while (1) { char *back = buf, *s, *post; @@ -197,7 +199,7 @@ static void *worker(void *data) { int is_post = 0, do_normal_send = 1; char *boundary = NULL; size_t boundary_len; - char *cmd, *path, *headers, path_copy[uw_bufsize+1], *inputs, *after_headers; + char *cmd, *path, *headers, *inputs, *after_headers; //printf("All: %s\n", buf); @@ -435,8 +437,14 @@ static void *worker(void *data) { printf("Serving URI %s....\n", path); while (1) { + size_t path_len = strlen(path); + uw_write_header(ctx, "HTTP/1.1 200 OK\r\n"); + if (path_len + 1 > path_copy_size) { + path_copy_size = path_len + 1; + path_copy = realloc(path_copy, path_copy_size); + } strcpy(path_copy, path); fk = uw_begin(ctx, path_copy); if (fk == SUCCESS || fk == RETURN_BLOB) { |