diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-03-15 16:41:29 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-03-16 14:42:56 -0400 |
commit | e84276124b4503240bce6511a6427e4a3e8327e5 (patch) | |
tree | f2af94385fe46aae00ab988a038cf1fd5d03e788 /src/or | |
parent | 91e3250bf16adb1732a10abec85dee26249c7851 (diff) | |
download | tor-e84276124b4503240bce6511a6427e4a3e8327e5.tar.gz tor-e84276124b4503240bce6511a6427e4a3e8327e5.zip |
Use a better for X outside of base64_compare_table.
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/consdiff.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/or/consdiff.c b/src/or/consdiff.c index 1009519d62..03762471e6 100644 --- a/src/or/consdiff.c +++ b/src/or/consdiff.c @@ -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) { |