]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Don't call strlen() when we only need to look at the next character or two.
authorSean Bright <sean@malleable.com>
Wed, 19 Jan 2011 19:02:29 +0000 (19:02 +0000)
committerSean Bright <sean@malleable.com>
Wed, 19 Jan 2011 19:02:29 +0000 (19:02 +0000)
(closes issue #18042)
Reported by: wdoekes
Patches:
      astsvn-inefficient-ast-uri-decode.patch uploaded by wdoekes (license 717)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.2@302554 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/utils.c

index 51f1283b532fd43754ff5d0bf2cb94b3db13c86b..cdf07451d352d9ddf21cd1a2df1b2a794dca65aa 100644 (file)
@@ -419,7 +419,7 @@ void ast_uri_decode(char *s)
        unsigned int tmp;
 
        for (o = s; *s; s++, o++) {
-               if (*s == '%' && strlen(s) > 2 && sscanf(s + 1, "%2x", &tmp) == 1) {
+               if (*s == '%' && s[1] != '\0' && s[2] != '\0' && sscanf(s + 1, "%2x", &tmp) == 1) {
                        /* have '%', two chars and correct parsing */
                        *o = tmp;
                        s += 2; /* Will be incremented once more when we break out */