From: Jiri Kosina <jikos@kernel.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] HID: hid-debug: clean up snprintf() checks in hid_resolv_usage()
Date: Wed, 22 Sep 2021 11:49:39 +0200 (CEST) [thread overview]
Message-ID: <nycvar.YFH.7.76.2109221149310.15944@cbobk.fhfr.pm> (raw)
In-Reply-To: <20210916132154.GC25094@kili>
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
prev parent reply other threads:[~2021-09-22 9:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-16 13:21 [PATCH] HID: hid-debug: clean up snprintf() checks in hid_resolv_usage() Dan Carpenter
2021-09-22 9:49 ` Jiri Kosina [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=nycvar.YFH.7.76.2109221149310.15944@cbobk.fhfr.pm \
--to=jikos@kernel.org \
--cc=benjamin.tissoires@redhat.com \
--cc=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).