From 1ded87ad8ad45592fa87c96edbb9a0be767bc1f1 Mon Sep 17 00:00:00 2001 From: Daan Hoogland Date: Fri, 12 Feb 2021 15:22:36 +0000 Subject: [PATCH] mysql connector does not properly defend against index out of bounds --- tools/marvin/marvin/dbConnection.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/marvin/marvin/dbConnection.py b/tools/marvin/marvin/dbConnection.py index a3c19d73759..0de4b6d55fc 100644 --- a/tools/marvin/marvin/dbConnection.py +++ b/tools/marvin/marvin/dbConnection.py @@ -17,11 +17,8 @@ import mysql import contextlib -from mysql import connector from mysql.connector import errors -from contextlib import closing from marvin import cloudstackException -import sys import os @@ -50,7 +47,9 @@ class DbConnection(object): with contextlib.closing(conn.cursor(buffered=True)) as cursor: cursor.execute(sql, params) try: - resultRow = cursor.fetchall() + if cursor.rowcount > 0: + # we have more than just the row count/success + resultRow = cursor.fetchall() except errors.InterfaceError: # Raised on empty result - DML resultRow = []