From 9f2f9bd8b02d805e452854f8c41dc463dad02d9e Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sun, 24 Dec 2023 22:09:09 +0000 Subject: [PATCH] Fixed some package math. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4695 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- src/http.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/http.c b/src/http.c index 6defc570..2b5efa03 100644 --- a/src/http.c +++ b/src/http.c @@ -221,11 +221,13 @@ static void _http_add_body_bytes(tf_http_connection_t* connection, const void* d p[mask_start + 2] << 16 | p[mask_start + 3] << 24; size_t i = 0; - for (i = mask_start + 4; i < length; i += 4) + size_t start = mask_start + 4; + size_t end = mask_start + 4 + length; + for (i = start; i < end; i += 4) { *(uint32_t*)(p + i) ^= mask; } - for (; i < length; i++) + for (; i < end; i++) { p[i] ^= ((mask >> (8 * (i % 4))) & 0xff); } @@ -233,7 +235,7 @@ static void _http_add_body_bytes(tf_http_connection_t* connection, const void* d { tf_printf("MESSAGE %d [%.*s]\n", opcode, (int)length, p + mask_start + 4); } - size_t total_length + mask_Start + 4 + length; + size_t total_length = end; memmove(connection->body, (char*)connection->body + total_length, connection->body_length - total_length); connection->body_length -= total_length; }