From: Alexander Nyberg <alexn@dsv.su.se>
To: linux-kernel@vger.kernel.org
Cc: campbell@torque.net, tim@cyberelk.net, Philip.Blundell@pobox.com
Subject: [PATCH] Possible off by one in drivers/parport/probe.c
Date: Wed, 01 Dec 2004 18:02:15 +0100 [thread overview]
Message-ID: <1101920536.718.61.camel@boxen> (raw)
Hi!
This fixes a theoretical bug indicated in:
http://bugme.osdl.org/show_bug.cgi?id=240
It prevents overflow in case the required buffer is larger than the passed
buffer. This I found to be the minimally intrusive change.
If anyone could test this change using parport with "IEEE 1284 transfer modes"
(CONFIG_PARPORT_1284) hardware it would be nice.
Signed-off-by: Alexander Nyberg <alexn@dsv.su.se>
===== drivers/parport/probe.c 1.6 vs edited =====
--- 1.6/drivers/parport/probe.c 2004-10-28 09:39:58 +02:00
+++ edited/drivers/parport/probe.c 2004-12-01 17:02:43 +01:00
@@ -164,8 +164,16 @@ ssize_t parport_device_id (int devnum, c
if (retval != 2) goto end_id;
idlen = (length[0] << 8) + length[1] - 2;
- if (idlen < len)
+ /*
+ * Check if the caller-allocated buffer is large enough
+ * otherwise bail out or there will be an at least off by one.
+ */
+ if (idlen + 1 < len)
len = idlen;
+ else {
+ retval = -ENOMEM;
+ goto out;
+ }
retval = parport_read (dev->port, buffer, len);
if (retval != len)
@@ -205,11 +213,12 @@ ssize_t parport_device_id (int devnum, c
buffer[len] = '\0';
parport_negotiate (dev->port, IEEE1284_MODE_COMPAT);
}
- parport_release (dev);
if (retval > 2)
parse_data (dev->port, dev->daisy, buffer);
+out:
+ parport_release (dev);
parport_close (dev);
return retval;
}
reply other threads:[~2004-12-01 17:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1101920536.718.61.camel@boxen \
--to=alexn@dsv.su.se \
--cc=Philip.Blundell@pobox.com \
--cc=campbell@torque.net \
--cc=linux-kernel@vger.kernel.org \
--cc=tim@cyberelk.net \
/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