From: Stanislav Malyshev Date: Fri, 8 Sep 2000 12:52:05 +0000 (+0000) Subject: Never trust snprintf return value X-Git-Tag: php-4.0.3RC1~243 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=522aec44430dd9484f58d2ad749bb3e3aafad59c;p=php Never trust snprintf return value --- diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index ee59e07933..90d2d4f255 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -568,6 +568,9 @@ static FILE *php_fopen_url_wrap_http(const char *path, char *mode, int options, len = snprintf(hdr_line, sizeof(hdr_line), "Host: %s\r\n", resource->host); } + if(len > sizeof(hdr_line) - 1) { + len = sizeof(hdr_line) - 1; + } if (len > 0) { SOCK_WRITE(hdr_line, *socketd); } diff --git a/main/main.c b/main/main.c index 43dd9e6886..a87cf5969b 100644 --- a/main/main.c +++ b/main/main.c @@ -317,6 +317,9 @@ PHPAPI int php_printf(const char *format, ...) va_start(args, format); size = vsnprintf(buffer, sizeof(buffer), format, args); + if(size > sizeof(buffer) - 1) { + size = sizeof(buffer) - 1; + } ret = PHPWRITE(buffer, size); va_end(args);