]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
Issue #792 - set errno=EINVAL if parsing the string in json_parse_int64 fails, to...
authorEric Haszlakiewicz <erh+git@nimenees.com>
Wed, 26 Oct 2022 02:19:38 +0000 (02:19 +0000)
committerEric Haszlakiewicz <erh+git@nimenees.com>
Wed, 26 Oct 2022 02:19:38 +0000 (02:19 +0000)
json_util.c

index 83d9c6831905a58a29381995c3b3e04c5b626ef2..1a2dfcdd8520165ab7b48177ed30773fa54f8e34 100644 (file)
@@ -247,7 +247,12 @@ int json_parse_int64(const char *buf, int64_t *retval)
        val = strtoll(buf, &end, 10);
        if (end != buf)
                *retval = val;
-       return ((val == 0 && errno != 0) || (end == buf)) ? 1 : 0;
+       if ((val == 0 && errno != 0) || (end == buf))
+       {
+               errno = EINVAL;
+               return 1;
+       }
+       return 0;
 }
 
 int json_parse_uint64(const char *buf, uint64_t *retval)