Skip to content

Commit

Permalink
strptime: fix overflow in conv_num (fluent#3161)
Browse files Browse the repository at this point in the history
Signed-off-by: davkor <david@adalogics.com>
  • Loading branch information
DavidKorczynski authored Mar 4, 2021
1 parent c62ad5a commit 7e5b733
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/flb_strptime.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,12 @@ _conv_num64(const unsigned char **buf, int64_t *dest, int64_t llim, int64_t ulim
result *= 10;
result += *(*buf)++ - '0';
rulim /= 10;
/* watch out for overflows. If value gets above
* ((2**64)/2.0)/10.0 then we will overflow. So instead
* we return 0 */
if (result >= 922337203685477632) {
return (0);
}
} while ((result * 10 <= ulim) && rulim && **buf >= '0' && **buf <= '9');

if (result < llim || result > ulim)
Expand Down

0 comments on commit 7e5b733

Please sign in to comment.