diff options
Diffstat (limited to 'src/net')
| -rw-r--r-- | src/net/luai.c | 6 | ||||
| -rw-r--r-- | src/net/util.c | 16 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/net/luai.c b/src/net/luai.c index 3e16dcb..205f217 100644 --- a/src/net/luai.c +++ b/src/net/luai.c @@ -75,7 +75,11 @@ int rolling_file_parse(lua_State* L, int* files_idx, int* body_idx, char* buffer //parray_set(content, "_current", (void*)(current)); content.boundary_id = str_init(""); - str_popb(content.boundary, 4); + + //quick fix? + //str_popb(content.boundary, 4); + if(content.boundary->len >= 4) str_popb(content.boundary, 4); + //parray_set(content, "_boundary", (void*)boundary); //parray_set(content, "_boundary_id", (void*)boundary_id); diff --git a/src/net/util.c b/src/net/util.c index 76ec30e..92d3bce 100644 --- a/src/net/util.c +++ b/src/net/util.c @@ -11,21 +11,21 @@ int64_t recv_header(int client_fd, char** _buffer, char** header_eof){ for(;;){ n = recv(client_fd, buffer + len, BUFFER_SIZE, 0); - if(n < 0){ - printf("%s %i\n", strerror(errno), errno); + if(n <= 0){ + //printf("%s %i\n", strerror(errno), errno); return -1; } - + + if((len += n) >= MAX_HEADER_SIZE){ + return -2; + } + // search the last 4 characters too if they exist // this could probably be changed to 3 int64_t start_len = len - 4 > 0 ? len - 4 : 0; int64_t search_end = len - 4 > 0 ? n + 4 : n; if((*header_eof = memmem(buffer + start_len, search_end, "\r\n\r\n", 4)) != NULL){ - return len + n; - } - - if((len += n) >= MAX_HEADER_SIZE){ - return -2; + return len; } buffer = realloc(buffer, sizeof* buffer * (len + BUFFER_SIZE + 1)); |
