mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +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;
|
int r;
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return -1; /* no place for the NUL */
|
return -1; /* no place for the NUL */
|
||||||
if (size > SIZE_T_CEILING)
|
if (size > SSIZE_T_MAX-16)
|
||||||
return -1;
|
return -1;
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
r = _vsnprintf(str, size, format, args);
|
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);
|
r = vsnprintf(str, size, format, args);
|
||||||
#endif
|
#endif
|
||||||
str[size-1] = '\0';
|
str[size-1] = '\0';
|
||||||
if (r < 0 || ((size_t)r) >= size)
|
if (r < 0 || r >= (ssize_t)size)
|
||||||
return -1;
|
return -1;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user