diff options
| author | ame <[email protected]> | 2025-08-05 15:07:31 -0500 |
|---|---|---|
| committer | ame <[email protected]> | 2025-08-05 15:07:31 -0500 |
| commit | ce33e309ad9dd3321e42ae623ac12fd739957259 (patch) | |
| tree | 50ca8b9e5209cdabe30a80e89fcdb455f51acf24 | |
| parent | 05cd214e8d4a4a3f560327f414a82d388cfe6755 (diff) | |
add length after check, duh
| -rw-r--r-- | src/net/util.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/net/util.c b/src/net/util.c index 3e91c7c..b41f0ed 100644 --- a/src/net/util.c +++ b/src/net/util.c @@ -16,16 +16,16 @@ int64_t recv_header(int client_fd, char** _buffer, char** header_eof){ 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 start_len = len - 4 > 0 ? len - 4 : len; 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; + return len + n; + } + + if((len += n) >= MAX_HEADER_SIZE){ + return -2; } buffer = realloc(buffer, sizeof* buffer * (len + BUFFER_SIZE + 1)); |
