nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Fix an rcfile out-of-bounds read on empty lines


From: Benno Schulenberg
Subject: Re: [PATCH] Fix an rcfile out-of-bounds read on empty lines
Date: Sun, 16 Feb 2020 13:45:05 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

Op 16-02-2020 om 13:12 schreef Saagar Jha:
> This is just a minor out-of-bounds fix in parse_rcfile.
> 
> [...]
>               /* Strip the terminating newline and possibly a carriage 
> return. */
> -             if (buffer[length - 1] == '\n')
> +             if (length && buffer[length - 1] == '\n')
>                       buffer[--length] = '\0';
> -             if (buffer[length - 1] == '\r')
> +             if (length && buffer[length - 1] == '\r')
>                       buffer[--length] = '\0';

Thanks for noticing this.  However... only half of it is needed: the
while loop starts with the equivalent of 'length > 0'.

Also, when posting a patch, please add a Signed-off-by line.  See the
last section in the README.GIT file.

Benno

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]