From: Richard Jones Date: Wed, 10 Jun 2009 10:11:14 +0000 (+0100) Subject: Add IS_DEVICE checks for all calls which take a device parameter. X-Git-Tag: 1.0.44~8 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=2df2f2854ed2d1f9857ef3c5aaca29810cf3c506;p=libguestfs.git Add IS_DEVICE checks for all calls which take a device parameter. --- diff --git a/daemon/ext2.c b/daemon/ext2.c index ab03528..4e1b398 100644 --- a/daemon/ext2.c +++ b/daemon/ext2.c @@ -122,6 +122,8 @@ do_set_e2label (const char *device, const char *label) int r; char *err; + IS_DEVICE (device, -1); + r = command (NULL, &err, "/sbin/e2label", device, label, NULL); if (r == -1) { reply_with_error ("e2label: %s", err); @@ -139,6 +141,8 @@ do_get_e2label (const char *device) int r, len; char *out, *err; + IS_DEVICE (device, NULL); + r = command (&out, &err, "/sbin/e2label", device, NULL); if (r == -1) { reply_with_error ("e2label: %s", err); @@ -163,6 +167,8 @@ do_set_e2uuid (const char *device, const char *uuid) int r; char *err; + IS_DEVICE (device, -1); + r = command (NULL, &err, "/sbin/tune2fs", "-U", uuid, device, NULL); if (r == -1) { reply_with_error ("tune2fs -U: %s", err); @@ -180,6 +186,8 @@ do_get_e2uuid (const char *device) int r; char *out, *err, *p, *q; + IS_DEVICE (device, NULL); + /* It's not so straightforward to get the volume UUID. We have * to use tune2fs -l and then look for a particular string in * the output. diff --git a/daemon/lvm.c b/daemon/lvm.c index 40377f1..c30d4e7 100644 --- a/daemon/lvm.c +++ b/daemon/lvm.c @@ -176,6 +176,8 @@ do_pvcreate (const char *device) char *err; int r; + IS_DEVICE (device, -1); + r = command (NULL, &err, "/sbin/lvm", "pvcreate", device, NULL); if (r == -1) { @@ -195,6 +197,8 @@ do_vgcreate (const char *volgroup, char * const* const physvols) int r, argc, i; const char **argv; + Xphysvols; + argc = count_strings (physvols) + 3; argv = malloc (sizeof (char *) * (argc + 1)); if (argv == NULL) { @@ -335,6 +339,8 @@ do_lvremove (const char *device) char *err; int r; + IS_DEVICE (device, -1); + r = command (NULL, &err, "/sbin/lvm", "lvremove", "-f", device, NULL); if (r == -1) { @@ -353,6 +359,8 @@ do_vgremove (const char *device) char *err; int r; + IS_DEVICE (device, -1); + r = command (NULL, &err, "/sbin/lvm", "vgremove", "-f", device, NULL); if (r == -1) { @@ -371,6 +379,8 @@ do_pvremove (const char *device) char *err; int r; + IS_DEVICE (device, -1); + r = command (NULL, &err, "/sbin/lvm", "pvremove", "-ff", device, NULL); if (r == -1) { @@ -389,6 +399,8 @@ do_pvresize (const char *device) char *err; int r; + IS_DEVICE (device, -1); + r = command (NULL, &err, "/sbin/lvm", "pvresize", device, NULL); if (r == -1) { diff --git a/daemon/mount.c b/daemon/mount.c index 4e0ecdb..071ca96 100644 --- a/daemon/mount.c +++ b/daemon/mount.c @@ -46,6 +46,8 @@ do_mount_vfs (const char *options, const char *vfstype, char *mp; char *error; + IS_DEVICE (device, -1); + is_root = strcmp (mountpoint, "/") == 0; if (!root_mounted && !is_root) { @@ -110,9 +112,10 @@ do_umount (const char *pathordevice) char *buf; char *err; - if (strncmp (pathordevice, "/dev/", 5) == 0) - buf = (char *) pathordevice; - else { + if (strncmp (pathordevice, "/dev/", 5) == 0) { + buf = pathordevice; + IS_DEVICE (buf, -1); + } else { len = strlen (pathordevice) + 9; freeit = 1; buf = malloc (len);