[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <nycvar.YFH.7.76.2109221149310.15944@cbobk.fhfr.pm>
Date: Wed, 22 Sep 2021 11:49:39 +0200 (CEST)
From: Jiri Kosina <jikos@...nel.org>
To: Dan Carpenter <dan.carpenter@...cle.com>
cc: Benjamin Tissoires <benjamin.tissoires@...hat.com>,
linux-input@...r.kernel.org, linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] HID: hid-debug: clean up snprintf() checks in
hid_resolv_usage()
On Thu, 16 Sep 2021, Dan Carpenter wrote:
> The snprintf() limits are complicated and slightly wrong when it does:
>
> max(0, HID_DEBUG_BUFSIZE - len - 1)
>
> The "- 1" should not be there. It means we can't use the last
> byte of the buffer. If we change the first snprintf() to scnprintf()
> then we can remove the max().
>
> At the start of the function the strlen(buf) is going always going to
> be < HID_DEBUG_BUFSIZE so that is safe. If it were > HID_DEBUG_BUFSIZE
> then that would result in a WARN().
Applied, thanks Dan.
--
Jiri Kosina
SUSE Labs
Powered by blists - more mailing lists