Skip to content

Commit

Permalink
m_option: fix scientific notation timestamp parsing
Browse files Browse the repository at this point in the history
Fixes: a173b47
  • Loading branch information
llyyr authored and kasper93 committed Jan 9, 2025
1 parent 7a59a12 commit f049a1e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions options/m_option.c
Original file line number Diff line number Diff line change
Expand Up @@ -2673,8 +2673,10 @@ static int parse_timestring(struct bstr str, double *time, char endchar)
bool neg = bstr_eatstart0(&str, "-");
if (!neg)
bstr_eatstart0(&str, "+");
if (bstrchr(str, '-') >= 0 || bstrchr(str, '+') >= 0)
return 0; /* the timestamp shouldn't contain anymore +/- after this point */
bool sci = bstr_find0(str, "e-") >= 0 || bstr_find0(str, "e+") >= 0;
/* non-scientific notation timestamps shouldn't contain anymore +/- after this point */
if (!sci && (bstrchr(str, '-') >= 0 || bstrchr(str, '+') >= 0))
return 0;
if (bstr_sscanf(str, "%u:%u:%lf%n", &h, &m, &s, &len) >= 3) {
if (m >= 60 || s >= 60)
return 0; /* minutes or seconds are out of range */
Expand Down

0 comments on commit f049a1e

Please sign in to comment.