Skip to contentSkip to conversation

partitions: aix.c: off by one bug

PATCH Applied Dan Carpenter 3 participants 4 messages Aug 5, 2014

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

PATCH 1/1 partitions: aix.c: off by one bug

The lvip[] array has "state->limit" elements so the condition here should be >= instead of >.

Fixes 6ceea22bbbc8 ('partitions: add aix lvm partition support files')
block/partitions/aix.c +1 -1
index 0a6ed54..f3ed7b2 100644
@@ -253,7 +253,7 @@ int aix_partition(struct parsed_partitions *state)
 				continue;
 			}
 			lv_ix = be16_to_cpu(p->lv_ix) - 1;
-			if (lv_ix > state->limit) {
+			if (lv_ix >= state->limit) {
 				cur_lv_ix = -1;
 				continue;
 			}
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Dan Carpenter

The lvip[] array has "state->limit" elements so the condition here should be >= instead of >.

Fixes 6ceea22bbbc8 ('partitions: add aix lvm partition support files')
block/partitions/aix.c +0 -0
index 0a6ed54..f3ed7b2 100644

block/partitions/aix.c int aix_partition(struct parsed_partitions *state) · line 259

Quoted 8 lines
block/partitions/aix.c +1 -1
@@ -253,7 +253,7 @@ int aix_partition(struct parsed_partitions *state)
 				continue;
 			}
 			lv_ix = be16_to_cpu(p->lv_ix) - 1;
-			if (lv_ix > state->limit) {
+			if (lv_ix >= state->limit) {
 				cur_lv_ix = -1;
 				continue;
 			}

Thanks

Did you encounter the bug in real life, or only by code review ?

If this has a real risk to happen, a pr_warn would be welcome.

Philippe

Signature · 1 line
Philippe De Muyter +32 2 6101532 Macq SA rue de l'Aeronef 2 B-1140 Bruxelles
#2 lore raw
Quoted 3 lines · Philippe De Muyter

Did you encounter the bug in real life, or only by code review ?

If this has a real risk to happen, a pr_warn would be welcome.

Static analysis.

regards,
dan carpenter

maintainer Applied
#3 lore raw
In reply to Dan Carpenter
Quoted 12 lines · Dan Carpenter

The lvip[] array has "state->limit" elements so the condition here should be >= instead of >.

Fixes 6ceea22bbbc8 ('partitions: add aix lvm partition support files')
block/partitions/aix.c +0 -0
index 0a6ed54..f3ed7b2 100644

block/partitions/aix.c int aix_partition(struct parsed_partitions *state) · line 259

Quoted 8 lines
block/partitions/aix.c +1 -1
@@ -253,7 +253,7 @@ int aix_partition(struct parsed_partitions *state)
 				continue;
 			}
 			lv_ix = be16_to_cpu(p->lv_ix) - 1;
-			if (lv_ix > state->limit) {
+			if (lv_ix >= state->limit) {
 				cur_lv_ix = -1;
 				continue;
 			}

Applied, thanks.

Signature · 1 line
Jens Axboe