mirror of
https://github.com/php/php-src.git
synced 2026-04-14 11:32:11 +02:00
Never trust snprintf return value
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user