]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
regression in %nn change, failed to handle trailing %
authorHenrik Nordstrom <henrik@henriknordstrom.net>
Wed, 4 Nov 2009 08:13:23 +0000 (09:13 +0100)
committerHenrik Nordstrom <henrik@henriknordstrom.net>
Wed, 4 Nov 2009 08:13:23 +0000 (09:13 +0100)
lib/rfc1738.c

index 278a543052c461e041d6117281ff7670b8f69040..59781156e05bf7b113f399d81d518f4cb8666535 100644 (file)
@@ -190,9 +190,8 @@ fromhex(char ch)
 }
 
 void
-rfc1738_unescape(char *s_)
+rfc1738_unescape(char *s)
 {
-    unsigned char *s = (unsigned char *) s_;
     int i, j;                  /* i is write, j is read */
     for (i = j = 0; s[j]; i++, j++) {
         s[i] = s[j];
@@ -203,15 +202,14 @@ rfc1738_unescape(char *s_)
         } else {
             /* decode */
             char v1, v2;
-            int x;
             v1 = fromhex(s[j + 1]);
+           if (v1 < 0)
+               continue;  /* non-hex or \0 */
             v2 = fromhex(s[j + 2]);
-            /* fromhex returns -1 on error which brings this out of range (|, not +) */
-            x = v1 << 4 | v2;
-            if (x > 0 && x <= 255) {
-                s[i] = x;
-                j += 2;
-            }
+           if (v2 < 0)
+               continue;  /* non-hex or \0 */
+           s[i] = v1 << 4 | v2;
+           j += 2;
         }
     }
     s[i] = '\0';