]> granicus.if.org Git - curl/commitdiff
tool_urlglob: Improve sanity check in glob_range
authorJay Satiro <raysatiro@yahoo.com>
Fri, 25 Nov 2016 03:25:14 +0000 (22:25 -0500)
committerJay Satiro <raysatiro@yahoo.com>
Fri, 25 Nov 2016 03:25:46 +0000 (22:25 -0500)
Prior to this change we depended on errno if strtol could not perform a
conversion. POSIX says EINVAL *may* be set. Some implementations like
Microsoft's will not set it if there's no conversion.

Ref: https://github.com/curl/curl/commit/ee4f7660#commitcomment-19658189

src/tool_urlglob.c

index 23fc7f39ed45ea5901e13c3b345f0aaa81445042..e68e30e84bc61f451f93a0e72148a79d18bbdc95 100644 (file)
@@ -201,7 +201,7 @@ static CURLcode glob_range(URLGlob *glob, char **patternp,
         unsigned long lstep;
         errno = 0;
         lstep = strtoul(&pattern[4], &endp, 10);
-        if(errno || (*endp != ']'))
+        if(errno || &pattern[4] == endp || *endp != ']')
           step = -1;
         else {
           pattern = endp+1;