[tor-commits] [tor/master] Fix integer overflows in the conversion tables

nickm at torproject.org nickm at torproject.org
Fri Aug 12 18:57:22 UTC 2016


commit 8d67c079b472a0a5c786abb3ba7db5ad571b6aed
Author: cypherpunks <cypherpunks at torproject.org>
Date:   Wed May 25 11:17:29 2016 +0000

    Fix integer overflows in the conversion tables
---
 changes/bug19168    | 3 +++
 src/common/compat.c | 4 ++--
 src/common/compat.h | 4 ++--
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/changes/bug19168 b/changes/bug19168
new file mode 100644
index 0000000..7bdfc50
--- /dev/null
+++ b/changes/bug19168
@@ -0,0 +1,3 @@
+  o Minor bugfixes (code correctness):
+    - Fix integer overflows in the case conversion tables. Fixes bug
+      19168; bugfix on 0.2.1.11-alpha.
diff --git a/src/common/compat.c b/src/common/compat.c
index b2ed119..4614ef9 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -645,7 +645,7 @@ const uint32_t TOR_ISLOWER_TABLE[8] = { 0, 0, 0, 0x7fffffe, 0, 0, 0, 0 };
 /** Upper-casing and lowercasing tables to map characters to upper/lowercase
  * equivalents.  Used by tor_toupper() and tor_tolower(). */
 /**@{*/
-const char TOR_TOUPPER_TABLE[256] = {
+const uint8_t TOR_TOUPPER_TABLE[256] = {
   0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
   16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
   32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
@@ -663,7 +663,7 @@ const char TOR_TOUPPER_TABLE[256] = {
   224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
   240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,
 };
-const char TOR_TOLOWER_TABLE[256] = {
+const uint8_t TOR_TOLOWER_TABLE[256] = {
   0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
   16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
   32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
diff --git a/src/common/compat.h b/src/common/compat.h
index 40bcb26..12f280d 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -360,8 +360,8 @@ DECLARE_CTYPE_FN(ISXDIGIT)
 DECLARE_CTYPE_FN(ISPRINT)
 DECLARE_CTYPE_FN(ISLOWER)
 DECLARE_CTYPE_FN(ISUPPER)
-extern const char TOR_TOUPPER_TABLE[];
-extern const char TOR_TOLOWER_TABLE[];
+extern const uint8_t TOR_TOUPPER_TABLE[];
+extern const uint8_t TOR_TOLOWER_TABLE[];
 #define TOR_TOLOWER(c) (TOR_TOLOWER_TABLE[(uint8_t)c])
 #define TOR_TOUPPER(c) (TOR_TOUPPER_TABLE[(uint8_t)c])
 





More information about the tor-commits mailing list