From: Jean Delvare <jdelvare@suse.de>
To: Linux I2C <linux-i2c@vger.kernel.org>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Subject: [PATCH 2/3] i2ctransfer: Prevent msgs[] overflow with many parameters
Date: Tue, 13 May 2025 17:23:30 +0200 [thread overview]
Message-ID: <20250513172330.1b6897d3@endymion> (raw)
In-Reply-To: <20250513172119.09548573@endymion>
There's an off-by-one bug in the message count check to ensure that we
do not process more messages than the kernel allows. nmsgs points to
the index within msgs[] which would be used for the _next_ message. If
this index is equal the maximum number of messages then we must stop
already.
This closes bug #220112:
https://bugzilla.kernel.org/show_bug.cgi?id=220112
Fixes: 9fc53a7fc669 ("i2c-tools: add new tool 'i2ctransfer'")
Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
tools/i2ctransfer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- i2c-tools.orig/tools/i2ctransfer.c
+++ i2c-tools/tools/i2ctransfer.c
@@ -193,7 +193,7 @@ int main(int argc, char *argv[])
__u8 data, *buf;
char *end;
- if (nmsgs > I2C_RDRW_IOCTL_MAX_MSGS) {
+ if (nmsgs == I2C_RDRW_IOCTL_MAX_MSGS) {
fprintf(stderr, "Error: Too many messages (max: %d)\n",
I2C_RDRW_IOCTL_MAX_MSGS);
goto err_out;
--
Jean Delvare
SUSE L3 Support
next prev parent reply other threads:[~2025-05-13 15:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-13 15:21 [PATCH 1/3] i2ctransfer: Don't free memory which was never allocated Jean Delvare
2025-05-13 15:23 ` Jean Delvare [this message]
2025-05-19 15:35 ` [PATCH 2/3] i2ctransfer: Prevent msgs[] overflow with many parameters Wolfram Sang
2025-05-13 15:35 ` [PATCH 3/3] i2ctransfer: Zero out memory passed to ioctl() Jean Delvare
2025-05-19 15:36 ` Wolfram Sang
2025-05-19 15:31 ` [PATCH 1/3] i2ctransfer: Don't free memory which was never allocated Wolfram Sang
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=20250513172330.1b6897d3@endymion \
--to=jdelvare@suse.de \
--cc=linux-i2c@vger.kernel.org \
--cc=wsa+renesas@sang-engineering.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.