提交 f714f528 编写于 作者: E Eric Farman 提交者: John Ferlan

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: NEric Farman <farman@linux.vnet.ibm.com>
上级 40783db3
...@@ -5024,20 +5024,20 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode, ...@@ -5024,20 +5024,20 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode,
goto cleanup; 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, virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse bus '%s'"), bus); _("cannot parse bus '%s'"), bus);
goto cleanup; goto cleanup;
} }
if (virStrToLong_ui(target, NULL, 0, if (virStrToLong_uip(target, NULL, 0,
&scsihostsrc->target) < 0) { &scsihostsrc->target) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse target '%s'"), target); _("cannot parse target '%s'"), target);
goto cleanup; 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, virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse unit '%s'"), unit); _("cannot parse unit '%s'"), unit);
goto cleanup; goto cleanup;
......
...@@ -480,15 +480,15 @@ static int str2SCSIAddress(const char *str, struct SCSIAddress *scsiAddr) ...@@ -480,15 +480,15 @@ static int str2SCSIAddress(const char *str, struct SCSIAddress *scsiAddr)
controller = (char *)str; controller = (char *)str;
if (virStrToLong_ui(controller, &bus, 0, &scsiAddr->controller) != 0) if (virStrToLong_uip(controller, &bus, 0, &scsiAddr->controller) != 0)
return -1; return -1;
bus++; bus++;
if (virStrToLong_ui(bus, &unit, 0, &scsiAddr->bus) != 0) if (virStrToLong_uip(bus, &unit, 0, &scsiAddr->bus) != 0)
return -1; return -1;
unit++; unit++;
if (virStrToLong_ui(unit, NULL, 0, &scsiAddr->unit) != 0) if (virStrToLong_uip(unit, NULL, 0, &scsiAddr->unit) != 0)
return -1; return -1;
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册