]> granicus.if.org Git - php/commitdiff
Never trust snprintf return value
authorStanislav Malyshev <stas@php.net>
Fri, 8 Sep 2000 12:52:05 +0000 (12:52 +0000)
committerStanislav Malyshev <stas@php.net>
Fri, 8 Sep 2000 12:52:05 +0000 (12:52 +0000)
main/fopen_wrappers.c
main/main.c

index ee59e079336edaa3bbe51607a9dd8016aa628a2d..90d2d4f25559ecef7e510361b31ad73629a3afc8 100644 (file)
@@ -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);
        }
index 43dd9e6886f5976f941fa254f90424b1cc1f827b..a87cf5969b360608489cf4047560120dac9eb171 100644 (file)
@@ -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);