From: Anatol Belski Date: Mon, 13 Oct 2014 09:32:13 +0000 (+0200) Subject: fix signed/unsigned mismatch X-Git-Tag: POST_NATIVE_TLS_MERGE^2~74^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=97319bc83357628b79d18702e82fba4b7f252e05;p=php fix signed/unsigned mismatch --- 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) {