summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2022-02-08 16:58:21 +0100
committerGravatar Nikias Bassen2022-02-08 16:58:21 +0100
commitd6026ca0e878ede5c1bd2be7c74fc0827e83824e (patch)
tree9822190d41679062c338a2ebb18dcd7b08e4be38 /src
parent19c17052d6cf9fe29039a1869b799efc0b687dc3 (diff)
downloadlibplist-d6026ca0e878ede5c1bd2be7c74fc0827e83824e.tar.gz
libplist-d6026ca0e878ede5c1bd2be7c74fc0827e83824e.tar.bz2
jplist: Prevent read of uninitialized value by checking the bounds beforehand
Credit to OSS-Fuzz
Diffstat (limited to 'src')
-rw-r--r--src/jplist.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/jplist.c b/src/jplist.c
index 6c6e331..e965870 100644
--- a/src/jplist.c
+++ b/src/jplist.c
@@ -486,7 +486,7 @@ static plist_t parse_primitive(const char* js, jsmntok_info_t* ti, int* index)
val = plist_new_node(data);
} else if (isdigit(str_val[0]) || (str_val[0] == '-' && str_end > str_val && isdigit(str_val[1]))) {
char* endp = (char*)str_val;
- long long intpart = parse_decimal(str_val, str_end, &endp);
+ int64_t intpart = parse_decimal(str_val, str_end, &endp);
if (endp >= str_end) {
/* integer */
val = plist_new_uint((uint64_t)intpart);
@@ -501,7 +501,7 @@ static plist_t parse_primitive(const char* js, jsmntok_info_t* ti, int* index)
int is_neg = (str_val[0] == '-');
double frac = 0;
double p = 0.1;
- while (isdigit(*fendp) && fendp < str_end) {
+ while (fendp < str_end && isdigit(*fendp)) {
frac = frac + (*fendp - '0') * p;
p *= 0.1;
fendp++;