Skip to contentSkip to conversation

qga: fix an off-by-one issue

PATCH Applied Li Qiang 3 participants 3 messages Oct 18, 2018 – Oct 30, 2018

lore
Share & tools
lore

Li Qiang

author
#0 lore raw

PATCH 1/1 qga: fix an off-by-one issue

---
 qga/commands-win32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qga/commands-win32.c +1 -1
index 98d9735..e3842d1 100644
@@ -465,7 +465,7 @@ static STORAGE_BUS_TYPE win2qemu[] = {
 
 static GuestDiskBusType find_bus_type(STORAGE_BUS_TYPE bus)
 {
-    if (bus > ARRAY_SIZE(win2qemu) || (int)bus < 0) {
+    if (bus >= ARRAY_SIZE(win2qemu) || (int)bus < 0) {
         return GUEST_DISK_BUS_TYPE_UNKNOWN;
     }
     return win2qemu[(int)bus];
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw

Missed in a3ef3b2272d.

Quoted 1 line · Li Qiang

Nice catch btw.

Quoted 18 lines
---
 qga/commands-win32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qga/commands-win32.c +1 -1
index 98d9735..e3842d1 100644
@@ -465,7 +465,7 @@ static STORAGE_BUS_TYPE win2qemu[] = {
 
 static GuestDiskBusType find_bus_type(STORAGE_BUS_TYPE bus)
 {
-    if (bus > ARRAY_SIZE(win2qemu) || (int)bus < 0) {
+    if (bus >= ARRAY_SIZE(win2qemu) || (int)bus < 0) {
         return GUEST_DISK_BUS_TYPE_UNKNOWN;
     }
     return win2qemu[(int)bus];
Applied
#2 lore raw
In reply to Li Qiang

Quoting Li Qiang (2018-10-17 21:10:37)

Quoted 1 line

Thanks, applied to qga tree:
https://github.com/mdroth/qemu/commits/qga

Quoted 20 lines
---
 qga/commands-win32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qga/commands-win32.c +1 -1
index 98d9735..e3842d1 100644
@@ -465,7 +465,7 @@ static STORAGE_BUS_TYPE win2qemu[] = {
 
 static GuestDiskBusType find_bus_type(STORAGE_BUS_TYPE bus)
 {
-    if (bus > ARRAY_SIZE(win2qemu) || (int)bus < 0) {
+    if (bus >= ARRAY_SIZE(win2qemu) || (int)bus < 0) {
         return GUEST_DISK_BUS_TYPE_UNKNOWN;
     }
     return win2qemu[(int)bus];
Signature · 1 line
1.8.3.1