[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Use a better for X outside of base64_compare_table.
commit e84276124b4503240bce6511a6427e4a3e8327e5
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Wed Mar 15 16:41:29 2017 -0400
Use a better for X outside of base64_compare_table.
---
src/or/consdiff.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/or/consdiff.c b/src/or/consdiff.c
index 1009519..0376247 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) {
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits