From b7ee1e8df5a4aa17a3f4e2ace0bc0bbe6bd75fa0 Mon Sep 17 00:00:00 2001 From: Sijmen Huizenga Date: Sat, 30 Sep 2023 19:09:52 +0200 Subject: [PATCH] parser: Fix hour validation in timezone offset parsing Signed-off-by: Sijmen Huizenga --- src/flb_parser.c | 5 +++-- tests/internal/parser.c | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/flb_parser.c b/src/flb_parser.c index 4ccecc91b1d..9e6a49233d8 100644 --- a/src/flb_parser.c +++ b/src/flb_parser.c @@ -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"); @@ -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; } diff --git a/tests/internal/parser.c b/tests/internal/parser.c index c4e4f235f98..e48925aabbd 100644 --- a/tests/internal/parser.c +++ b/tests/internal/parser.c @@ -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}, @@ -42,6 +43,7 @@ struct tz_check tz_entries_error[] = { {"0000", 0}, {"+00:90", 0}, {"--600", 0}, + {"+24:00", 0}, {"foo", 0}, };