All of lore.kernel.org
 help / color / mirror / Atom feed
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: Sat, 13 Oct 2018 10:38:40 +0000	[thread overview]
Message-ID: <20181013103840.GA22816@mwanda> (raw)

The > should be >= or otherwise we could end up reading one element
beyond the end of the array.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 block/partitions/ldm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/partitions/ldm.c b/block/partitions/ldm.c
index 16766f267559..f48bcd2f5226 100644
--- a/block/partitions/ldm.c
+++ b/block/partitions/ldm.c
@@ -636,7 +636,7 @@ 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)
-- 
2.18.0

WARNING: multiple messages have this Message-ID (diff)
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: Sat, 13 Oct 2018 13:38:40 +0300	[thread overview]
Message-ID: <20181013103840.GA22816@mwanda> (raw)

The > should be >= or otherwise we could end up reading one element
beyond the end of the array.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 block/partitions/ldm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/partitions/ldm.c b/block/partitions/ldm.c
index 16766f267559..f48bcd2f5226 100644
--- a/block/partitions/ldm.c
+++ b/block/partitions/ldm.c
@@ -636,7 +636,7 @@ 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)
-- 
2.18.0

             reply	other threads:[~2018-10-13 10:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-13 10:38 Dan Carpenter [this message]
2018-10-13 10:38 ` [PATCH] partitions/ldm: Off by one in ldm_relative() Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2018-06-20 10:44 Dan Carpenter
2018-06-20 10:44 ` 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=20181013103840.GA22816@mwanda \
    --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 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.