Skip to content

Commit 5949473

Browse files
DavidKorczynskiedsiper
authored andcommitted
parser: fix overflow
Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=52414 Signed-off-by: David Korczynski <[email protected]>
1 parent 1837c5a commit 5949473

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/flb_parser.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,12 @@ int flb_parser_tzone_offset(const char *str, int len, int *tmdiff)
973973
return -1;
974974
}
975975

976+
/* Ensure there is enough data */
977+
if (len < 4) {
978+
*tmdiff = 0;
979+
return -1;
980+
}
981+
976982
/* Negative value ? */
977983
neg = (*p++ == '-');
978984

@@ -982,6 +988,11 @@ int flb_parser_tzone_offset(const char *str, int len, int *tmdiff)
982988
/* Gather hours and minutes */
983989
hour = ((p[0] - '0') * 10) + (p[1] - '0');
984990
if (end - p == 5 && p[2] == ':') {
991+
/* Ensure there is enough data */
992+
if (len < 5) {
993+
*tmdiff = 0;
994+
return -1;
995+
}
985996
min = ((p[3] - '0') * 10) + (p[4] - '0');
986997
}
987998
else {

0 commit comments

Comments
 (0)