OSSP CVS Repository

ossp - Ticket #167
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Attach]  [Edit]  [History

Ticket 167: [str] cached patterns lookup problem

Function pattern_lookup() uses incorrect algorithm to search cached pattern. If you have a cached pattern then this function will always select the last cached pattern for any patterns with the same hash values.

Please look at my patch fixing it.

--- str-0.9.12/str_parse.c 2008-04-29 10:02:26 UTC (rev 15300) +++ str-0.9.12/str_parse.c 2008-04-29 10:03:37 UTC (rev 15301) @@ -204,14 +204,15 @@ *p_pcre_extra = NULL;

     h = hash_func(key, keylen);
-    if ((he = pattern_hash[h]) == NULL)
-        return;
-    while (he->next != NULL) {
+    he = pattern_hash[h];
+    while (he != NULL) {
         if (he->keylen == keylen)
             if (memcmp(he->key, key, keylen))
                 break;
         he = he->next;
     }
+    if (he == NULL)
+        return;
     *p_pcre = he->p_pcre;
     *p_pcre_extra = he->p_pcre_extra;
     return;
[Append remarks]

Remarks:

Thanks. You're right, the algorithm was broken. Now fixed by taken over your patch.
[Append remarks]

Properties:

Type: code           Version: 0.9.12 
Status: fixed          Created: 2008-Apr-29 13:15
Severity:          Last Change: 2008-Jun-06 14:31
Priority:          Subsystem: str 
Assigned To: rse           Derived From:  
Creator: anonymous 

CVSTrac 2.0.1