1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-09 01:18:00 +03:00

virsh: reject more negative numbers

Be more positive and reject negative numbers where we don't
allow them by using the virStrToLong variants with 'p'.

https://bugzilla.redhat.com/show_bug.cgi?id=1436119
This commit is contained in:
Ján Tomko 2017-03-27 14:17:42 +02:00
parent 2da7f545a3
commit df6551feb4
3 changed files with 15 additions and 15 deletions

View File

@ -438,19 +438,19 @@ static int str2PCIAddress(const char *str, struct PCIAddress *pciAddr)
domain = (char *)str;
if (virStrToLong_ui(domain, &bus, 16, &pciAddr->domain) != 0)
if (virStrToLong_uip(domain, &bus, 16, &pciAddr->domain) != 0)
return -1;
bus++;
if (virStrToLong_ui(bus, &slot, 16, &pciAddr->bus) != 0)
if (virStrToLong_uip(bus, &slot, 16, &pciAddr->bus) != 0)
return -1;
slot++;
if (virStrToLong_ui(slot, &function, 16, &pciAddr->slot) != 0)
if (virStrToLong_uip(slot, &function, 16, &pciAddr->slot) != 0)
return -1;
function++;
if (virStrToLong_ui(function, NULL, 16, &pciAddr->function) != 0)
if (virStrToLong_uip(function, NULL, 16, &pciAddr->function) != 0)
return -1;
return 0;
@ -492,15 +492,15 @@ static int str2IDEAddress(const char *str, struct IDEAddress *ideAddr)
controller = (char *)str;
if (virStrToLong_ui(controller, &bus, 10, &ideAddr->controller) != 0)
if (virStrToLong_uip(controller, &bus, 10, &ideAddr->controller) != 0)
return -1;
bus++;
if (virStrToLong_ui(bus, &unit, 10, &ideAddr->bus) != 0)
if (virStrToLong_uip(bus, &unit, 10, &ideAddr->bus) != 0)
return -1;
unit++;
if (virStrToLong_ui(unit, NULL, 10, &ideAddr->unit) != 0)
if (virStrToLong_uip(unit, NULL, 10, &ideAddr->unit) != 0)
return -1;
return 0;
@ -517,15 +517,15 @@ static int str2CCWAddress(const char *str, struct CCWAddress *ccwAddr)
cssid = (char *)str;
if (virStrToLong_ui(cssid, &ssid, 16, &ccwAddr->cssid) != 0)
if (virStrToLong_uip(cssid, &ssid, 16, &ccwAddr->cssid) != 0)
return -1;
ssid++;
if (virStrToLong_ui(ssid, &devno, 16, &ccwAddr->ssid) != 0)
if (virStrToLong_uip(ssid, &devno, 16, &ccwAddr->ssid) != 0)
return -1;
devno++;
if (virStrToLong_ui(devno, NULL, 16, &ccwAddr->devno) != 0)
if (virStrToLong_uip(devno, NULL, 16, &ccwAddr->devno) != 0)
return -1;
return 0;
@ -8428,7 +8428,7 @@ virshKeyCodeGetInt(const char *key_name)
{
unsigned int val;
if (virStrToLong_ui(key_name, NULL, 0, &val) < 0 || val > 0xffff)
if (virStrToLong_uip(key_name, NULL, 0, &val) < 0 || val > 0xffff)
return -1;
return val;
}

View File

@ -209,7 +209,7 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
for (i = 0; i < nodes_cnt; i++) {
unsigned long id;
char *val = virXMLPropString(nodes[i], "id");
if (virStrToLong_ul(val, NULL, 10, &id)) {
if (virStrToLong_ulp(val, NULL, 10, &id)) {
vshError(ctl, "%s", _("conversion from string failed"));
VIR_FREE(val);
goto cleanup;
@ -355,7 +355,7 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd)
for (i = 0; i < nodes_cnt; i++) {
char *val = virXMLPropString(nodes[i], "size");
if (virStrToLong_ui(val, NULL, 10, &pagesize[i]) < 0) {
if (virStrToLong_uip(val, NULL, 10, &pagesize[i]) < 0) {
vshError(ctl, _("unable to parse page size: %s"), val);
VIR_FREE(val);
goto cleanup;
@ -554,7 +554,7 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd)
for (i = 0; i < nodes_cnt; i++) {
unsigned long id;
char *val = virXMLPropString(nodes[i], "id");
if (virStrToLong_ul(val, NULL, 10, &id)) {
if (virStrToLong_ulp(val, NULL, 10, &id)) {
vshError(ctl, "%s", _("conversion from string failed"));
VIR_FREE(val);
goto cleanup;

View File

@ -206,7 +206,7 @@ static int
virshVolSize(const char *data, unsigned long long *val)
{
char *end;
if (virStrToLong_ull(data, &end, 10, val) < 0)
if (virStrToLong_ullp(data, &end, 10, val) < 0)
return -1;
return virScaleInteger(val, end, 1, ULLONG_MAX);
}