Skip to contentSkip to conversation

vector: fix upper boundary check of vector size in vector_del_slot

PATCH In review Zhiqiang Liu 2 participants 2 messages Aug 3, 2020 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vector: fix upper boundary check of vector size in vector_del_slot

In vector_del_slot func, legal value of input slot is in range of [0, VECTOR_SIZE(v)), it means slot value should be less then VECTOR_SIZE(v).

---
 libmultipath/vector.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libmultipath/vector.c +1 -1
index 501cf4c5..5b047e40 100644
@@ -109,7 +109,7 @@ vector_del_slot(vector v, int slot)
 {
 	int i;
 
-	if (!v || !v->allocated || slot < 0 || slot > VECTOR_SIZE(v))
+	if (!v || !v->allocated || slot < 0 || slot >= VECTOR_SIZE(v))
 		return;
 
 	for (i = slot + 1; i < VECTOR_SIZE(v); i++)
Signature · 1 line
2.24.0.windows.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Zhiqiang Liu

In vector_del_slot func, legal value of input slot is in range of [0, VECTOR_SIZE(v)), it means slot value should be less then VECTOR_SIZE(v).

Quoted 20 lines
---
 libmultipath/vector.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libmultipath/vector.c +1 -1
index 501cf4c5..5b047e40 100644
@@ -109,7 +109,7 @@ vector_del_slot(vector v, int slot)
 {
 	int i;
 
-	if (!v || !v->allocated || slot < 0 || slot > VECTOR_SIZE(v))
+	if (!v || !v->allocated || slot < 0 || slot >= VECTOR_SIZE(v))
 		return;
 
 	for (i = slot + 1; i < VECTOR_SIZE(v); i++)
Signature · 1 line
2.24.0.windows.2