diff options
author | Jo-Philipp Wich <jo@mein.io> | 2024-10-16 12:09:31 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2024-10-16 12:09:31 +0200 |
commit | 4134e7182624b37bf17d91fc89b500f5cb443187 (patch) | |
tree | 5a4878d66d02b9f832e34096574083e409fd2858 /vallist.c | |
parent | 9cf53dda36bc25b513ec1b1cdfc851a10b37473f (diff) |
vallist: more thoroughly check for trailing garbage after numeric string
When converting numeric strings into numbers, ensure that only optional
trailing whitespace follows and no other characters.
Fixes: #231
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'vallist.c')
-rw-r--r-- | vallist.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -106,7 +106,10 @@ uc_number_parse_common(const char *buf, bool octal, char **end) if (base >= 10 && (**end == '.' || (**end|32) == 'e')) { d = strtod(p, end); - if (!isspace(**end) && **end != 0) + while (isspace(**end)) + (*end)++; + + if (**end != 0) return NULL; if (neg) @@ -115,7 +118,10 @@ uc_number_parse_common(const char *buf, bool octal, char **end) return ucv_double_new(d); } - if (!isspace(**end) && **end != 0) + while (isspace(**end)) + (*end)++; + + if (**end != 0) return NULL; if (neg) { |