]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: tools: improve time format error detection
authorWilly Tarreau <w@1wt.eu>
Fri, 7 Jun 2019 17:00:37 +0000 (19:00 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 7 Jun 2019 17:32:02 +0000 (19:32 +0200)
commit9faebe34cdbf3fcc0e23936aefbbdfa493997b12
tree5b0fd4fbcf658d7e4596e8bc6640d13dc2ba9141
parentb65717fa55fe01e9972e7c809c775d948922a03c
MEDIUM: tools: improve time format error detection

As reported in GH issue #109 and in discourse issue
https://discourse.haproxy.org/t/haproxy-returns-408-or-504-error-when-timeout-client-value-is-every-25d
the time parser doesn't error on overflows nor underflows. This is a
recurring problem which additionally has the bad taste of taking a long
time before hitting the user.

This patch makes parse_time_err() return special error codes for overflows
and underflows, and adds the control in the call places to report suitable
errors depending on the requested unit. In practice, underflows are almost
never returned as the parsing function takes care of rounding values up,
so this might possibly happen on 64-bit overflows returning exactly zero
after rounding though. It is not really possible to cut the patch into
pieces as it changes the function's API, hence all callers.

Tests were run on about every relevant part (cookie maxlife/maxidle,
server inter, stats timeout, timeout*, cli's set timeout command,
tcp-request/response inspect-delay).
15 files changed:
include/common/standard.h
src/arg.c
src/cfgparse-global.c
src/cfgparse-listen.c
src/cfgparse.c
src/cli.c
src/flt_spoe.c
src/hlua.c
src/proto_tcp.c
src/proxy.c
src/server.c
src/ssl_sock.c
src/standard.c
src/stick_table.c
src/tcp_rules.c