Am 23.06.20 um 17:37 schrieb Willy Tarreau:
> On Tue, Jun 23, 2020 at 05:06:27PM +0200, Tim Duesterhus wrote:
>> Otherwise `arg++` will be executed for every argument after the maximum,
>> returning a bogus value.
> No, it returns the correct one, as documented at the beginning of the
> function:
>   ... <args> are not updated beyond <nbargs> but the returned <nbargs>
>        indicates how many were found.
> The purpose was to allow the caller to realloc() its array if it wants
> to read all the args. I couldn't find a single case where this arg is
> dereferenced inside the function so for me it's OK, but I could very
> well miss something.

I should read the comment :-)

> I think the problem you've spotted is entirely related to what you've
> fixed in the second patch in fact. Instead of args[arg-1] we need to
> use args[MAX_LINE_ARGS-1] which is the limit we've passed to the
> function. And of course your change from thisline to outline is right.

Oh, yeah. That's obviously correct, because we know how many arguments
we requested.

Updated series coming in.

Best regards

Tim Düsterhus (2):
  BUG/MINOR: cfgparse: Fix argument reference in PARSE_ERR_TOOMANY
  BUG/MINOR: cfgparse: Fix calculation of position for PARSE_ERR_TOOMANY

 src/cfgparse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


Reply via email to