Skip to content

Commit

Permalink
parser: Fix hour validation in timezone offset parsing
Browse files Browse the repository at this point in the history
Signed-off-by: Sijmen Huizenga <[email protected]>
  • Loading branch information
SijmenHuizenga committed Sep 30, 2023
1 parent 1cef8e2 commit b7ee1e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/flb_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,8 @@ static int parser_conf_file(const char *cfg, struct flb_cf *cf,
name, cfg);
goto fconf_early_error;
}



/* skip_empty_values */
skip_empty = FLB_TRUE;
tmp_str = get_parser_key(config, cf, s, "skip_empty_values");
Expand Down Expand Up @@ -1040,7 +1041,7 @@ int flb_parser_tzone_offset(const char *str, int len, int *tmdiff)
min = ((p[2] - '0') * 10) + (p[3] - '0');
}

if (hour < 0 || hour > 59 || min < 0 || min > 59) {
if (hour < 0 || hour > 23 || min < 0 || min > 59) {
return -1;
}

Expand Down
2 changes: 2 additions & 0 deletions tests/internal/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct tz_check tz_entries_ok[] = {
{"+0000", 0},
{"+00:00", 0},
{"+00:59", 3540},
{"+23:59", 86340},
{"-0600", -21600},
{"-06:00", -21600},
{"Z", 0},
Expand All @@ -42,6 +43,7 @@ struct tz_check tz_entries_error[] = {
{"0000", 0},
{"+00:90", 0},
{"--600", 0},
{"+24:00", 0},
{"foo", 0},
};

Expand Down

0 comments on commit b7ee1e8

Please sign in to comment.