lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Sat, 21 Jun 2008 02:17:26 -0700 From: "Joonwoo Park" <joonwpark81@...il.com> To: "Patrick McHardy" <kaber@...sh.net> Cc: "Pablo Neira Ayuso" <pablo@...filter.org>, netdev <netdev@...r.kernel.org>, netfilter-devel <netfilter-devel@...r.kernel.org> Subject: Re: [PATCH 3/8] textsearch: fix Boyer-Moore algorithm for case insensitive searching 2008/6/21 Patrick McHardy <kaber@...sh.net>: > Joonwoo Park wrote: >> >> @@ -75,7 +77,9 @@ static unsigned int bm_find(struct ts_config *conf, >> struct ts_state *state) >> DEBUGP("Searching in position %d (%c)\n", >> shift, text[shift]); >> for (i = 0; i < bm->patlen; i++) - >> if (text[shift-i] != bm->pattern[bm->patlen-1-i]) >> + if ((icase ? toupper(text[shift-i]) >> + : text[shift-i]) >> + != bm->pattern[bm->patlen-1-i]) >> goto next; >> /* London calling... */ >> @@ -111,14 +115,18 @@ static int subpattern(u8 *pattern, int i, int j, int >> g) >> return ret; >> } >> -static void compute_prefix_tbl(struct ts_bm *bm) >> +static void compute_prefix_tbl(struct ts_bm *bm, u8 icase) >> { >> int i, j, g; >> for (i = 0; i < ASIZE; i++) >> bm->bad_shift[i] = bm->patlen; >> - for (i = 0; i < bm->patlen - 1; i++) >> + for (i = 0; i < bm->patlen - 1; i++) { >> bm->bad_shift[bm->pattern[i]] = bm->patlen - 1 - i; >> + if (icase) >> + bm->bad_shift[tolower(bm->pattern[i])] >> + = bm->patlen - 1 - i; >> + } > > You use toupper() above and tolower() here, is that correct? > It should be, bm->pattern's characters are all upper case since It was altered before. So we should use toupper() for target string character to compare. And to ignore case, we should prepare one more bad_shift array calculation, opposite tolower() should be used for it. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@...r.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists