scsi: fix allocation for s390x loadparm
PATCH 1/1 scsi: fix allocation for s390x loadparm
Coverity reports a possible buffer overrun due to a non-NUL-terminated string in scsi_property_set_loadparm(). While things are not so easy, because qdev_prop_sanitize_s390x_loadparm is designed to operate on a buffer that is not NUL-terminated, in this case the string *does* have to be NUL-terminated because it is read by scsi_property_get_loadparm and s390_build_iplb.
--- hw/scsi/scsi-disk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/scsi-disk.c +1 -1
@@ -3152,7 +3152,7 @@ static void scsi_property_set_loadparm(Object *obj, const char *value,return ; } - lp_str =g_malloc0 (strlen (value)); + lp_str =g_malloc0 (strlen (value) +1 );if (!qdev_prop_sanitize_s390x_loadparm (lp_str, value, errp)) {g_free (lp_str);return ;
Signature · 1 line
2.47.0
Quoted 19 lines · Paolo Bonzini
Coverity reports a possible buffer overrun due to a non-NUL-terminated string in
scsi_property_set_loadparm(). While things are not so easy, becauseqdev_prop_sanitize_s390x_loadparmis designed to operate on a buffer that is not NUL-terminated, in this case the string *does* have to be NUL-terminated because it is read byscsi_property_get_loadparmands390_build_iplb.--- hw/scsi/scsi-disk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/scsi/scsi-disk.c +0
-0
hw/scsi/scsi-disk.c static void scsi_property_set_loadparm(Object *obj, const char *value, · line 3158
Quoted 8 lines
hw/scsi/scsi-disk.c +1
-1@@ -3152,7 +3152,7 @@ static void scsi_property_set_loadparm(Object *obj, const char *value,return ; } - lp_str =g_malloc0 (strlen (value)); + lp_str =g_malloc0 (strlen (value) +1 );if (!qdev_prop_sanitize_s390x_loadparm (lp_str, value, errp)) {g_free (lp_str);return ;
Reviewed-by Jared Rossi <[email protected]>
Quoted 10 lines · Paolo Bonzini
Coverity reports a possible buffer overrun due to a non-NUL-terminated string in
scsi_property_set_loadparm(). While things are not so easy, becauseqdev_prop_sanitize_s390x_loadparmis designed to operate on a buffer that is not NUL-terminated, in this case the string *does* have to be NUL-terminated because it is read byscsi_property_get_loadparmands390_build_iplb.
hw/scsi/scsi-disk.c static void scsi_property_set_loadparm(Object *obj, const char *value, · line 3155
Quoted 10 lines
hw/scsi/scsi-disk.c +1
-1@@ -3152,7 +3152,7 @@ static void scsi_property_set_loadparm(Object *obj, const char *value,return ; } - lp_str =g_malloc0 (strlen (value)); + lp_str =g_malloc0 (strlen (value) +1 );
D'oh, me looks for a brown paperbag for hiding... sorry for that one.