Skip to contentSkip to conversation

partitions/ldm: Off by one in ldm_relative()

PATCH New Dan Carpenter 1 participant 1 message Oct 13, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 partitions/ldm: Off by one in ldm_relative()

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

---
 block/partitions/ldm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/partitions/ldm.c +1 -1
index 16766f267559..f48bcd2f5226 100644
@@ -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)
Signature · 1 line
2.18.0