mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
Make virsh -d check its input
it was using atoi direct without checking leading to confusion in case of flag error for example with -c * tools/virsh.c: vshParseArgv() use virStrToLong_i and remove the unchecked atoi used to parse teh parameter
This commit is contained in:
parent
fd5b15ff1a
commit
b259bab8e7
@ -11021,7 +11021,10 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
|
|||||||
while ((arg = getopt_long(end, argv, "d:hqtc:vrl:", opt, &idx)) != -1) {
|
while ((arg = getopt_long(end, argv, "d:hqtc:vrl:", opt, &idx)) != -1) {
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
case 'd':
|
case 'd':
|
||||||
ctl->debug = atoi(optarg);
|
if (virStrToLong_i(optarg, NULL, 10, &ctl->debug) < 0) {
|
||||||
|
vshError(ctl, _("option -d takes a numeric argument"), arg);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
help = 1;
|
help = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user