@@ -565,7 +565,7 @@ static void hour_type_print(const struct expr *expr, struct output_ctx *octx)
cur_tm = localtime(&ts);
if (cur_tm)
- seconds += cur_tm->tm_gmtoff;
+ seconds = (seconds + cur_tm->tm_gmtoff) % 86400;
__hour_type_print_r(0, 0, seconds, out);
nft_print(octx, "\"%s\"", out);
@@ -616,8 +616,12 @@ convert:
result = tm.tm_hour * 3600 + tm.tm_min * 60 + tm.tm_sec;
/* Substract tm_gmtoff to get the current time */
- if (cur_tm)
- result -= cur_tm->tm_gmtoff;
+ if (cur_tm) {
+ if (result >= cur_tm->tm_gmtoff)
+ result -= cur_tm->tm_gmtoff;
+ else
+ result = 86400 - cur_tm->tm_gmtoff + result;
+ }
success:
*res = constant_expr_alloc(&sym->location, sym->dtype,
This patch fixes an overflow error that would happen when introducing edge times whose second representation is smaller than the value of the tm_gmtoff field, such as 00:00. Signed-off-by: Ander Juaristi <a@juaristi.eus> --- src/meta.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)