]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Make SIZE_T_CEILING unsigned; add a signed SSIZE_T_CEILING
authorNick Mathewson <nickm@torproject.org>
Tue, 26 Apr 2011 17:00:46 +0000 (13:00 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 26 Apr 2011 17:03:58 +0000 (13:03 -0400)
None of the comparisons were _broken_ previously, but avoiding
signed/unsigned comparisons makes everybody happier.

Fixes bug2475.

changes/bug2475 [new file with mode: 0644]
src/common/crypto.c
src/common/torint.h

diff --git a/changes/bug2475 b/changes/bug2475
new file mode 100644 (file)
index 0000000..d6f0595
--- /dev/null
@@ -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.
index 48c8dea08fd5732df5d5f1081f35d8df43f3ee7e..838347e20ebfccd67649237f62181db6f052d37e 100644 (file)
@@ -452,7 +452,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);
index 2a9fba6fcf7846de1949102a15195c83b48019aa..d4896846561b8233a1fbb4c7bc0a40902e1b9ea1 100644 (file)
@@ -330,8 +330,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 */