From f714f528820282db416b96735cfba60d5767baa2 Mon Sep 17 00:00:00 2001 From: Eric Farman Date: Tue, 16 Jun 2015 23:29:51 -0400 Subject: [PATCH] Read SCSI address attributes bus, target, unit as positive integer The SCSI address element attributes bus, target, and unit are expected to be positive values, so make sure no one provides a negative value since the value is stored as an unsigned. Signed-off-by: Eric Farman --- src/conf/domain_conf.c | 6 +++--- tools/virsh-domain.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index bda0514b02..0a871ac8da 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5024,20 +5024,20 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode, goto cleanup; } - if (virStrToLong_ui(bus, NULL, 0, &scsihostsrc->bus) < 0) { + if (virStrToLong_uip(bus, NULL, 0, &scsihostsrc->bus) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse bus '%s'"), bus); goto cleanup; } - if (virStrToLong_ui(target, NULL, 0, + if (virStrToLong_uip(target, NULL, 0, &scsihostsrc->target) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse target '%s'"), target); goto cleanup; } - if (virStrToLong_ui(unit, NULL, 0, &scsihostsrc->unit) < 0) { + if (virStrToLong_uip(unit, NULL, 0, &scsihostsrc->unit) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse unit '%s'"), unit); goto cleanup; diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 4e890f4063..afdc61eef6 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -480,15 +480,15 @@ static int str2SCSIAddress(const char *str, struct SCSIAddress *scsiAddr) controller = (char *)str; - if (virStrToLong_ui(controller, &bus, 0, &scsiAddr->controller) != 0) + if (virStrToLong_uip(controller, &bus, 0, &scsiAddr->controller) != 0) return -1; bus++; - if (virStrToLong_ui(bus, &unit, 0, &scsiAddr->bus) != 0) + if (virStrToLong_uip(bus, &unit, 0, &scsiAddr->bus) != 0) return -1; unit++; - if (virStrToLong_ui(unit, NULL, 0, &scsiAddr->unit) != 0) + if (virStrToLong_uip(unit, NULL, 0, &scsiAddr->unit) != 0) return -1; return 0;