mysql connector does not properly defend against index out of bounds

This commit is contained in:
Daan Hoogland 2021-02-12 15:22:36 +00:00
parent 6a8c8159b6
commit 1ded87ad8a
1 changed files with 3 additions and 4 deletions

View File

@ -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 = []