[PATCH] os: prevent negative array index access (#80890)
walter harms
wharms at bfs.de
Tue Jul 8 04:22:12 PDT 2014
Am 08.07.2014 01:24, schrieb Peter Hutterer:
> If an empty string is provided to LogMessageVerbSigSafe, the length of the
> printed string is 0.
>
> Read-only access only and the only effect it had was adding a linebreak or not.
>
> X.Org Bug 80890 <http://bugs.freedesktop.org/show_bug.cgi?id=80890>
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
> Keith, please merge this directly if you're happy with it.
>
> os/log.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/os/log.c b/os/log.c
> index a368569..2a721b9 100644
> --- a/os/log.c
> +++ b/os/log.c
> @@ -697,7 +697,7 @@ LogVMessageVerbSigSafe(MessageType type, int verb, const char *format, va_list a
> if (sizeof(buf) - len == 1)
> buf[len - 1] = '\n';
>
> - newline = (buf[len - 1] == '\n');
> + newline = (len > 0 && buf[len - 1] == '\n');
> LogSWrite(verb, buf, len, newline);
> }
>
would it be more easy to
if (len <=0)
return ;
re,
wh
More information about the xorg-devel
mailing list