]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: pattern: pattern comparison executed twice
authorThierry FOURNIER <tfournier@exceliance.fr>
Tue, 14 Jan 2014 12:38:40 +0000 (13:38 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 14 Jan 2014 14:42:59 +0000 (15:42 +0100)
If the pattern is set as case insensitive, the string comparison
is executed twice. The first time is insensitive comparison, the
second is sensitive.

This is a recent bug, no backport is needed.

src/pattern.c

index 8380c636fef30393dea6695d3519c5d71e55abae..38b13835c495974b9274b6dd7637937147f80e67 100644 (file)
@@ -1222,11 +1222,14 @@ browse_list:
                                continue;
                        if (pattern.len != pat->len)
                                continue;
-                       if ((pat->flags & PAT_F_IGNORE_CASE) &&
-                           strncasecmp(pattern.ptr.str, pat->ptr.str, pat->len) != 0)
-                               continue;
-                       if (strncmp(pattern.ptr.str, pat->ptr.str, pat->len) != 0)
-                               continue;
+                       if (pat->flags & PAT_F_IGNORE_CASE) {
+                               if (strncasecmp(pattern.ptr.str, pat->ptr.str, pat->len) != 0)
+                                       continue;
+                       }
+                       else {
+                               if (strncmp(pattern.ptr.str, pat->ptr.str, pat->len) != 0)
+                                       continue;
+                       }
                        goto found;
                }
        }
@@ -1245,11 +1248,14 @@ browse_list:
                list_for_each_entry(pat, &expr->patterns, list) {
                        if (pat->flags & PAT_F_TREE)
                                continue;
-                       if ((pat->flags & PAT_F_IGNORE_CASE) &&
-                           strcasecmp(pattern.ptr.reg->regstr, pat->ptr.reg->regstr) != 0)
-                               continue;
-                       if (strcmp(pattern.ptr.reg->regstr, pat->ptr.reg->regstr) != 0)
-                               continue;
+                       if (pat->flags & PAT_F_IGNORE_CASE) {
+                               if (strcasecmp(pattern.ptr.reg->regstr, pat->ptr.reg->regstr) != 0)
+                                       continue;
+                       }
+                       else {
+                               if (strcmp(pattern.ptr.reg->regstr, pat->ptr.reg->regstr) != 0)
+                                       continue;
+                       }
                        goto found;
                }
        }