]> git.ipfire.org Git - thirdparty/haproxy.git/commit
[MEDIUM] Handle long lines properly
authorKrzysztof Piotr Oledzki <ole@ans.pl>
Wed, 31 Oct 2007 23:33:12 +0000 (00:33 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 1 Nov 2007 22:00:51 +0000 (23:00 +0100)
commite6bbd7469066ea8f8655c23ee43bd3f2b3463fa3
treea5a93808d4bf3c7603295fb2fc635ef015fef258
parent0259419f41fededcee0b6a61f8aab94bc9609b80
[MEDIUM] Handle long lines properly

Currently, there is a hidden line length limit in the haproxy, set
to 256-1 chars. With large acls (for example many hdr(host) matches)
it may be not enough and which is even worse, error message may
be totally confusing as everything above this limit is treated
as a next line:

echo -ne "frontend aqq 1.2.3.4:80\nmode http\nacl e hdr(host) -i X X X X X X X www.xx.example.com stats\n"|
 sed s/X/www.some-host-name.example.com/g > ha.cfg && haproxy -c -f ./ha.cfg

[WARNING] 300/163906 (11342) : parsing [./ha.cfg:4] : 'stats' ignored because frontend 'aqq' has no backend capability.

Recently I hit simmilar problem and it took me a while to find why
requests for "stats" are not handled properly.

This patch:
 - makes the limit configurable (LINESIZE)
 - increases default line length limit from 256 to 2048
 - increases MAX_LINE_ARGS from 40 to 64
 - fixes hidden assignment in fgets()
 - moves arg/end/args/line inside the loop, making code auditing easier
 - adds a check that shows error if the limit is reached
 - changes "*line++ = 0;" to "*line++ = '\0';" (cosmetics)

With this patch, when LINESIZE is defined to 256, above example produces:
[ALERT] 300/164724 (27364) : parsing [/tmp/ha.cfg:3]: line too long, limit: 255.
[ALERT] 300/164724 (27364) : Error reading configuration file : /tmp/ha.cfg
include/common/defaults.h
src/cfgparse.c