mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
Lower sprintf buffer max to ~SSIZE_T_MAX from SIZE_T_CEILING, since we need to compare it to a signed int.
svn:r17600
This commit is contained in:
parent
b20694758e
commit
98066d62bc
@ -303,7 +303,7 @@ tor_vsnprintf(char *str, size_t size, const char *format, va_list args)
|
||||
int r;
|
||||
if (size == 0)
|
||||
return -1; /* no place for the NUL */
|
||||
if (size > SIZE_T_CEILING)
|
||||
if (size > SSIZE_T_MAX-16)
|
||||
return -1;
|
||||
#ifdef MS_WINDOWS
|
||||
r = _vsnprintf(str, size, format, args);
|
||||
@ -311,7 +311,7 @@ tor_vsnprintf(char *str, size_t size, const char *format, va_list args)
|
||||
r = vsnprintf(str, size, format, args);
|
||||
#endif
|
||||
str[size-1] = '\0';
|
||||
if (r < 0 || ((size_t)r) >= size)
|
||||
if (r < 0 || r >= (ssize_t)size)
|
||||
return -1;
|
||||
return r;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user