diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-12-11 21:11:22 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-12-11 21:11:22 +0000 |
commit | 98066d62bc154393d36a04e3d26c87e9eff2c06f (patch) | |
tree | 41ffa24d1f0ac2ea5b66e8154aed9c7222639b9a | |
parent | b20694758e9014578ab4c1c7762b0a79bbf2b625 (diff) | |
download | tor-98066d62bc154393d36a04e3d26c87e9eff2c06f.tar.gz tor-98066d62bc154393d36a04e3d26c87e9eff2c06f.zip |
Lower sprintf buffer max to ~SSIZE_T_MAX from SIZE_T_CEILING, since we need to compare it to a signed int.
svn:r17600
-rw-r--r-- | src/common/compat.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/common/compat.c b/src/common/compat.c index 51172d77be..e506a2b975 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -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; } |