From: Dan Carpenter <dan.carpenter@oracle.com>
To: "Richard Russon (FlatCap)" <ldm@flatcap.org>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-ntfs-dev@lists.sourceforge.net,
linux-block@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] partitions/ldm: Off by one in ldm_relative()
Date: Wed, 20 Jun 2018 13:44:35 +0300 [thread overview]
Message-ID: <20180620104433.qegf5bakvcywzuga@kili.mountain> (raw)
If base == buflen then we read one character past the end of buffer[].
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This is static analysis. Not tested. This code goes back to before the
start of git.
diff --git a/block/partitions/ldm.c b/block/partitions/ldm.c
index 0417937dfe99..8f4c302eb11b 100644
--- a/block/partitions/ldm.c
+++ b/block/partitions/ldm.c
@@ -636,12 +636,12 @@ static int ldm_relative(const u8 *buffer, int buflen, int base, int offset)
{
base += offset;
- if (!buffer || offset < 0 || base > buflen) {
+ if (!buffer || offset < 0 || base >= buflen) {
if (!buffer)
ldm_error("!buffer");
if (offset < 0)
ldm_error("offset (%d) < 0", offset);
- if (base > buflen)
+ if (base >= buflen)
ldm_error("base (%d) > buflen (%d)", base, buflen);
return -1;
}
next reply other threads:[~2018-06-20 10:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-20 10:44 Dan Carpenter [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-10-13 10:38 [PATCH] partitions/ldm: Off by one in ldm_relative() Dan Carpenter
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=20180620104433.qegf5bakvcywzuga@kili.mountain \
--to=dan.carpenter@oracle.com \
--cc=axboe@kernel.dk \
--cc=kernel-janitors@vger.kernel.org \
--cc=ldm@flatcap.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-ntfs-dev@lists.sourceforge.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