Date: Thu, 9 Aug 2007 19:10:21 GMT From: Fredrik Lindberg <fli@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 124966 for review Message-ID: <200708091910.l79JALVB086510@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=124966 Change 124966 by fli@fli_nexus on 2007/08/09 19:09:21 Ignore case when comparing record names. Affected files ... .. //depot/projects/soc2007/fli-mdns_sd/mdnsd/record.c#4 edit Differences ... ==== //depot/projects/soc2007/fli-mdns_sd/mdnsd/record.c#4 (text+ko) ==== @@ -31,6 +31,7 @@ #include "debug.h" #include "log.h" #include "record.h" +#include "utf8.h" #define record_aquire(r) (r)->r_refcnt++; \ dprintf(DEBUG_REC, "Refcount on r=%x increased to %d",\ @@ -95,14 +96,17 @@ int record_get(struct records *recs, struct record **r, int flags, char *name) { - size_t len; + ssize_t len; struct record *rec; + char namlc[MDNS_RECORD_LEN+1]; MDNS_INIT_ASSERT(recs, r_magic); - len = strlen(name); - rec = hashtbl_find(&recs->r_recs, name, len); - + len = utf8_tolower(name, namlc, MDNS_RECORD_LEN); + if (len <= 0) + return (-1); + + rec = hashtbl_find(&recs->r_recs, namlc, len); if (rec == NULL && (flags & RECORD_NOINIT)) { *r = NULL; return (0); @@ -123,7 +127,7 @@ (*r)->r_flags = flags; TAILQ_INIT(&((*r)->r_list)); memcpy((*r)->r_name, name, len+1); - hashtbl_add(&recs->r_recs, (*r)->r_name, len, *r, 0); + hashtbl_add(&recs->r_recs, namlc, len, *r, HASHTBL_KEYDUP); } else { *r = rec; @@ -142,8 +146,9 @@ void record_release(struct record *r) { - size_t len; + ssize_t len; struct records *recs; + char namlc[MDNS_RECORD_LEN+1]; MDNS_INIT_ASSERT(r, r_magic); recs = r->r_recs; @@ -151,8 +156,8 @@ if (--r->r_refcnt == 0) { assert(TAILQ_EMPTY(&r->r_list) == 1); - len = strlen(r->r_name); - hashtbl_del(&recs->r_recs, r->r_name, len); + len = utf8_tolower(r->r_name, namlc, MDNS_RECORD_LEN); + hashtbl_del(&recs->r_recs, namlc, len); MDNS_INIT_UNSET(r, r_magic); if (!(r->r_flags & RECORD_NOALLOC)) free(r); @@ -193,12 +198,16 @@ record_find(struct records *recs, char *name) { struct record *r; - size_t len; + ssize_t len; + char namlc[MDNS_RECORD_LEN+1]; MDNS_INIT_ASSERT(recs, r_magic); - len = strlen(name); - r = hashtbl_find(&recs->r_recs, name, len); + len = utf8_tolower(name, namlc, MDNS_RECORD_LEN); + if (len <= 0) + return (NULL); + + r = hashtbl_find(&recs->r_recs, namlc, len); return (r); } @@ -367,12 +376,16 @@ struct record *r; struct record_type *rt; struct record_res *rr; - size_t len; + ssize_t len; + char namlc[MDNS_RECORD_LEN+1]; MDNS_INIT_ASSERT(recs, r_magic); - len = strlen(name); - r = hashtbl_find(&recs->r_recs, name, len); + len = utf8_tolower(name, namlc, MDNS_RECORD_LEN); + if (len <= 0) + return (NULL); + + r = hashtbl_find(&recs->r_recs, namlc, len); if (r == NULL) return (NULL); @@ -396,12 +409,16 @@ { struct record *r; struct record_type *rt; - size_t len; + ssize_t len; + char namlc[MDNS_RECORD_LEN+1]; MDNS_INIT_ASSERT(recs, r_magic); - len = strlen(name); - r = hashtbl_find(&recs->r_recs, name, len); + len = utf8_tolower(name, namlc, MDNS_RECORD_LEN); + if (len <= 0) + return (NULL); + + r = hashtbl_find(&recs->r_recs, namlc, len); if (r == NULL) return (NULL);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708091910.l79JALVB086510>