Willy,
Lukas,

sorry, I forgot to hit save on my cover-letter before running git
send-email. Here's what I *actually* wanted to say:
Am 22.06.20 um 22:10 schrieb Lukas Tribus:
>> So what we could do if we want to do something clean is the following:
>>   - detect \0 or truncation on a line and note its position ;
>>   - if we find another line once a truncated line has been found, we
>>     emit a warning about "stray NUL character at position X on line Y,
>>     this will not be supported in 2.3 anymore" and reset this position.
>>   - at the end of the loop, if the last NUL position is still set, we
>>     emit a warning about "missing LF on last line, file might have been
>>     truncated, this will not be supported in 2.3 anymore".
>>
>> And in 2.3 we turn that into errors.
>>
>> What do you guys think about it ?
> 
> I like it, yes.

Find a patch attached.

I tested this with:

    printf "listen foo\nbind *:8080\x00test\nmode http\x00stuff\nlog
global\x00bad\n"

And this is the result:

    $ ./haproxy -c -f ./example.cfg
    [WARNING] 173/225406 (30776) : parsing [./example.cfg:2]: Stray NUL
character at position 12. This will become a hard error in HAProxy 2.3.
    [WARNING] 173/225406 (30776) : parsing [./example.cfg:3]: Stray NUL
character at position 10. This will become a hard error in HAProxy 2.3.
    [WARNING] 173/225406 (30776) : parsing [./example.cfg:4]: Missing LF
on last line, file might have been truncated at position 11. This will
become a hard error in HAProxy 2.3.
    [WARNING] 173/225406 (30776) : config : missing timeouts for proxy
'foo'.
       | While not properly invalid, you will certainly encounter
various problems
       | with such a configuration. To fix this, please ensure that all
following
       | timeouts are set to a non-zero value: 'client', 'connect',
'server'.
    Warnings were found.
    Configuration file is valid

I guess a truncated last line cannot be differentiated from file that
does not
end with a new line, because fgets() consumes the full line (triggering the
eof), even if reading a NUL byte?

Best regards
Tim Düsterhus

Reply via email to