From 97319bc83357628b79d18702e82fba4b7f252e05 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 13 Oct 2014 11:32:13 +0200 Subject: [PATCH] fix signed/unsigned mismatch --- sapi/cgi/cgi_main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index dead1c3213..f06787543e 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -509,8 +509,13 @@ static size_t sapi_cgi_read_post(char *buffer, size_t count_bytes TSRMLS_DC) { size_t read_bytes = 0; int tmp_read_bytes; + size_t remaining_bytes; - count_bytes = MIN(count_bytes, SG(request_info).content_length - SG(read_post_bytes)); + assert(SG(request_info).content_length >= SG(read_post_bytes)); + + remaining_bytes = (size_t)(SG(request_info).content_length - SG(read_post_bytes)); + + count_bytes = MIN(count_bytes, remaining_bytes); while (read_bytes < count_bytes) { tmp_read_bytes = read(STDIN_FILENO, buffer + read_bytes, count_bytes - read_bytes); if (tmp_read_bytes <= 0) { -- 2.50.1