diff mbox series

qga: fix an off-by-one issue

Message ID 1539828637-2907-1-git-send-email-liq3ea@gmail.com (mailing list archive)
State New, archived
Headers show
Series qga: fix an off-by-one issue | expand

Commit Message

Li Qiang Oct. 18, 2018, 2:10 a.m. UTC
Signed-off-by: Li Qiang <liq3ea@gmail.com>
---
 qga/commands-win32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Philippe Mathieu-Daudé Oct. 18, 2018, 10:30 a.m. UTC | #1
Missed in a3ef3b2272d.

On 18/10/2018 04:10, Li Qiang wrote:
> Signed-off-by: Li Qiang <liq3ea@gmail.com>

Nice catch btw.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>  qga/commands-win32.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> index 98d9735..e3842d1 100644
> --- a/qga/commands-win32.c
> +++ b/qga/commands-win32.c
> @@ -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];
>
Michael Roth Oct. 30, 2018, 2:31 p.m. UTC | #2
Quoting Li Qiang (2018-10-17 21:10:37)
> Signed-off-by: Li Qiang <liq3ea@gmail.com>

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

> ---
>  qga/commands-win32.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> index 98d9735..e3842d1 100644
> --- a/qga/commands-win32.c
> +++ b/qga/commands-win32.c
> @@ -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];
> -- 
> 1.8.3.1
>
diff mbox series

Patch

diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 98d9735..e3842d1 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -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];