]> www.infradead.org Git - mtd-utils.git/commitdiff
flash_{un,}lock: don't allow "last byte + 1"
authorBrian Norris <computersforpeace@gmail.com>
Mon, 31 Aug 2015 21:34:55 +0000 (14:34 -0700)
committerBrian Norris <computersforpeace@gmail.com>
Wed, 11 Nov 2015 22:05:36 +0000 (14:05 -0800)
A lock/unlock/islocked ioctl() should be prevented from anything past
the last byte, inclusive. But we were doing an exclusive check.

This isn't a big deal, as the kernel MTD APIs would be guarding this
anyway, but let's do this for completeness.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
flash_unlock.c

index 7a7a773d1d763875d719987518812b17a1a126c2..d775c0b01950e64a7c9ae8b6823e7dc68b1cdc2b 100644 (file)
@@ -168,7 +168,7 @@ int main(int argc, char *argv[])
        } else {
                mtdLockInfo.start = 0;
        }
-       if (mtdLockInfo.start > mtdInfo.size)
+       if (mtdLockInfo.start >= mtdInfo.size)
                errmsg_die("%#x is beyond device size %#x",
                        mtdLockInfo.start, mtdInfo.size);