Skip to content

Commit b7ee1e8

Browse files
parser: Fix hour validation in timezone offset parsing
Signed-off-by: Sijmen Huizenga <[email protected]>
1 parent 1cef8e2 commit b7ee1e8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/flb_parser.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,8 @@ static int parser_conf_file(const char *cfg, struct flb_cf *cf,
530530
name, cfg);
531531
goto fconf_early_error;
532532
}
533-
533+
534+
534535
/* skip_empty_values */
535536
skip_empty = FLB_TRUE;
536537
tmp_str = get_parser_key(config, cf, s, "skip_empty_values");
@@ -1040,7 +1041,7 @@ int flb_parser_tzone_offset(const char *str, int len, int *tmdiff)
10401041
min = ((p[2] - '0') * 10) + (p[3] - '0');
10411042
}
10421043

1043-
if (hour < 0 || hour > 59 || min < 0 || min > 59) {
1044+
if (hour < 0 || hour > 23 || min < 0 || min > 59) {
10441045
return -1;
10451046
}
10461047

tests/internal/parser.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct tz_check tz_entries_ok[] = {
3333
{"+0000", 0},
3434
{"+00:00", 0},
3535
{"+00:59", 3540},
36+
{"+23:59", 86340},
3637
{"-0600", -21600},
3738
{"-06:00", -21600},
3839
{"Z", 0},
@@ -42,6 +43,7 @@ struct tz_check tz_entries_error[] = {
4243
{"0000", 0},
4344
{"+00:90", 0},
4445
{"--600", 0},
46+
{"+24:00", 0},
4547
{"foo", 0},
4648
};
4749

0 commit comments

Comments
 (0)