]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Use a better for X outside of base64_compare_table.
authorNick Mathewson <nickm@torproject.org>
Wed, 15 Mar 2017 20:41:29 +0000 (16:41 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 16 Mar 2017 18:42:56 +0000 (14:42 -0400)
src/or/consdiff.c

index 1009519d62cbd8a92f5bef7e1f043af6a898918f..03762471e6281ec4e68ea2831b6f50dc1d9efdc8 100644 (file)
@@ -333,9 +333,10 @@ calc_changes(smartlist_slice_t *slice1,
 }
 
 /* This table is from crypto.c. The SP and PAD defines are different. */
-#define X 255
-#define SP X
-#define PAD X
+#define NOT_VALID_BASE64 255
+#define X NOT_VALID_BASE64
+#define SP NOT_VALID_BASE64
+#define PAD NOT_VALID_BASE64
 static const uint8_t base64_compare_table[256] = {
   X, X, X, X, X, X, X, X, X, SP, SP, SP, X, SP, X, X,
   X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X,
@@ -378,7 +379,8 @@ get_id_hash(const cdline_t *line, cdline_t *hash_out)
   /* Stop when the first non-base64 character is found. Use unsigned chars to
    * avoid negative indexes causing crashes.
    */
-  while (base64_compare_table[*((unsigned char*)hash_end)] != X &&
+  while (base64_compare_table[*((unsigned char*)hash_end)]
+           != NOT_VALID_BASE64 &&
          hash_end < line->s + line->len) {
     hash_end++;
   }
@@ -458,15 +460,15 @@ base64cmp(const cdline_t *hash1, const cdline_t *hash2)
   while (1) {
     uint8_t av = base64_compare_table[*a];
     uint8_t bv = base64_compare_table[*b];
-    if (av == X) {
-      if (bv == X) {
+    if (av == NOT_VALID_BASE64) {
+      if (bv == NOT_VALID_BASE64) {
         /* Both ended with exactly the same characters. */
         return 0;
       } else {
         /* hash2 goes on longer than hash1 and thus hash1 is lower. */
         return -1;
       }
-    } else if (bv == X) {
+    } else if (bv == NOT_VALID_BASE64) {
       /* hash1 goes on longer than hash2 and thus hash1 is greater. */
       return 1;
     } else if (av < bv) {