From af891b3d6d3f6ee6e848411cc9e477c96e955f98 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Wed, 9 Sep 2015 11:29:39 +0200 Subject: [PATCH] make sure our case insensitive hash uses dns_tolower and not tolower which might conceivably do all kinds of locale things which could be slow --- pdns/misc.cc | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pdns/misc.cc b/pdns/misc.cc index bea87be2b..57eec1975 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -933,9 +933,9 @@ uint32_t burtleCI(const unsigned char* k, uint32_t length, uint32_t initval) /*---------------------------------------- handle most of the key */ while (len >= 12) { - a += (tolower(k[0]) +((uint32_t)tolower(k[1])<<8) +((uint32_t)tolower(k[2])<<16) +((uint32_t)tolower(k[3])<<24)); - b += (tolower(k[4]) +((uint32_t)tolower(k[5])<<8) +((uint32_t)tolower(k[6])<<16) +((uint32_t)tolower(k[7])<<24)); - c += (tolower(k[8]) +((uint32_t)tolower(k[9])<<8) +((uint32_t)tolower(k[10])<<16)+((uint32_t)tolower(k[11])<<24)); + a += (dns_tolower(k[0]) +((uint32_t)dns_tolower(k[1])<<8) +((uint32_t)dns_tolower(k[2])<<16) +((uint32_t)dns_tolower(k[3])<<24)); + b += (dns_tolower(k[4]) +((uint32_t)dns_tolower(k[5])<<8) +((uint32_t)dns_tolower(k[6])<<16) +((uint32_t)dns_tolower(k[7])<<24)); + c += (dns_tolower(k[8]) +((uint32_t)dns_tolower(k[9])<<8) +((uint32_t)dns_tolower(k[10])<<16)+((uint32_t)dns_tolower(k[11])<<24)); burtlemix(a,b,c); k += 12; len -= 12; } @@ -943,18 +943,18 @@ uint32_t burtleCI(const unsigned char* k, uint32_t length, uint32_t initval) /*------------------------------------- handle the last 11 bytes */ c += length; switch(len) { /* all the case statements fall through */ - case 11: c+=((uint32_t)tolower(k[10])<<24); - case 10: c+=((uint32_t)tolower(k[9])<<16); - case 9 : c+=((uint32_t)tolower(k[8])<<8); + case 11: c+=((uint32_t)dns_tolower(k[10])<<24); + case 10: c+=((uint32_t)dns_tolower(k[9])<<16); + case 9 : c+=((uint32_t)dns_tolower(k[8])<<8); /* the first byte of c is reserved for the length */ - case 8 : b+=((uint32_t)tolower(k[7])<<24); - case 7 : b+=((uint32_t)tolower(k[6])<<16); - case 6 : b+=((uint32_t)tolower(k[5])<<8); - case 5 : b+=tolower(k[4]); - case 4 : a+=((uint32_t)tolower(k[3])<<24); - case 3 : a+=((uint32_t)tolower(k[2])<<16); - case 2 : a+=((uint32_t)tolower(k[1])<<8); - case 1 : a+=tolower(k[0]); + case 8 : b+=((uint32_t)dns_tolower(k[7])<<24); + case 7 : b+=((uint32_t)dns_tolower(k[6])<<16); + case 6 : b+=((uint32_t)dns_tolower(k[5])<<8); + case 5 : b+=dns_tolower(k[4]); + case 4 : a+=((uint32_t)dns_tolower(k[3])<<24); + case 3 : a+=((uint32_t)dns_tolower(k[2])<<16); + case 2 : a+=((uint32_t)dns_tolower(k[1])<<8); + case 1 : a+=dns_tolower(k[0]); /* case 0: nothing left to add */ } burtlemix(a,b,c); -- 2.40.0