diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-04-27 22:14:54 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-04-27 22:14:54 -0400 |
commit | 26456d33546b674d5fa4d2c0112eeec561da7279 (patch) | |
tree | 04a13ff2f5f4cce7625bc0cc487fe439bacf6157 | |
parent | 26c022ecbcbf4fb4541c4103b5fc94831d50d92b (diff) | |
parent | 0130e7c9d2842ad58e1b84829aeab16a2efba3bb (diff) | |
download | tor-26456d33546b674d5fa4d2c0112eeec561da7279.tar tor-26456d33546b674d5fa4d2c0112eeec561da7279.tar.gz |
Merge remote-tracking branch 'origin/maint-0.2.2'
-rw-r--r-- | changes/bug2475 | 5 | ||||
-rw-r--r-- | src/common/crypto.c | 2 | ||||
-rw-r--r-- | src/common/torint.h | 4 |
3 files changed, 9 insertions, 2 deletions
diff --git a/changes/bug2475 b/changes/bug2475 new file mode 100644 index 000000000..d6f0595a5 --- /dev/null +++ b/changes/bug2475 @@ -0,0 +1,5 @@ + o Minor bugfixes: + - Avoid signed/unsigned comparisons by making SIZE_T_CEILING unsigned. + (None of the cases where we did this before were wrong, but by making + this change we can avoid warnings.) Fixes bug2475; bugfix on + Tor 0.2.1.28. diff --git a/src/common/crypto.c b/src/common/crypto.c index 6fed55a27..424fd09b6 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -523,7 +523,7 @@ crypto_pk_read_private_key_from_string(crypto_pk_env_t *env, tor_assert(env); tor_assert(s); - tor_assert(len < INT_MAX && len < SIZE_T_CEILING); + tor_assert(len < INT_MAX && len < SSIZE_T_CEILING); /* Create a read-only memory BIO, backed by the string 's' */ b = BIO_new_mem_buf((char*)s, (int)len); diff --git a/src/common/torint.h b/src/common/torint.h index f5bebf8b9..0b5c29adc 100644 --- a/src/common/torint.h +++ b/src/common/torint.h @@ -329,8 +329,10 @@ typedef uint32_t uintptr_t; #endif #endif +/** Any ssize_t larger than this amount is likely to be an underflow. */ +#define SSIZE_T_CEILING ((ssize_t)(SSIZE_T_MAX-16)) /** Any size_t larger than this amount is likely to be an underflow. */ -#define SIZE_T_CEILING (SSIZE_T_MAX-16) +#define SIZE_T_CEILING ((size_t)(SSIZE_T_MAX-16)) #endif /* __TORINT_H */ |