Commit 6a9b1bee authored by Mark Andrews's avatar Mark Andrews

use canonical form of the name server name in saveglue and findglue

parent d1497b14
Pipeline #5384 passed with stages
in 1 minute and 10 seconds
...@@ -3092,7 +3092,9 @@ static struct glue * ...@@ -3092,7 +3092,9 @@ static struct glue *
findglue(char *ns) { findglue(char *ns) {
unsigned int hash = 0; unsigned int hash = 0;
struct glue *item; struct glue *item;
char *t = ns; char buf[1024], *t = buf;
ns_makecanon(ns, buf, sizeof(buf));
while (*t != 0) { while (*t != 0) {
hash = hash << 3 | hash >> 29; hash = hash << 3 | hash >> 29;
hash ^= (*t++ & 0x5f); /* ignore case */ hash ^= (*t++ & 0x5f); /* ignore case */
...@@ -3100,7 +3102,7 @@ findglue(char *ns) { ...@@ -3100,7 +3102,7 @@ findglue(char *ns) {
hash %= 100000; hash %= 100000;
for (item = gluetable[hash]; item != NULL; item = item->next) { for (item = gluetable[hash]; item != NULL; item = item->next) {
if (strcasecmp(ns, item->name) == 0) if (strcasecmp(buf, item->name) == 0)
break; break;
} }
return (item); return (item);
...@@ -3111,24 +3113,24 @@ saveglue(char *ns, char *address) { ...@@ -3111,24 +3113,24 @@ saveglue(char *ns, char *address) {
unsigned int hash = 0; unsigned int hash = 0;
struct glue *item; struct glue *item;
struct linked_address *la; struct linked_address *la;
char *t = ns; char buf[1024], *t = buf;
ns_makecanon(ns, buf, sizeof(buf));
while (*t != 0) { while (*t != 0) {
hash = hash << 3 | hash >> 29; hash = hash << 3 | hash >> 29;
hash ^= (*t++ & 0x5f); /* ignore case */ hash ^= (*t++ & 0x5f); /* ignore case */
} }
hash %= 100000; hash %= 100000;
for (item = gluetable[hash]; item != NULL; item = item->next) { for (item = gluetable[hash]; item != NULL; item = item->next) {
if (strcasecmp(ns, item->name) == 0) if (strcasecmp(buf, item->name) == 0)
break; break;
} }
if (item == NULL) { if (item == NULL) {
item = calloc(1, sizeof(*item)); item = calloc(1, sizeof(*item));
if (item == NULL) if (item == NULL)
return; return;
item->name = strdup(ns); item->name = strdup(buf);
if (item->name == NULL) { if (item->name == NULL) {
free(item); free(item);
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment