[libvirt] [PATCH] qemu: Allow loading snapshot configs starting with a dot

Relax the check for the period on start of a snapshot name to skip only the '.' and '..' directories. --- src/qemu/qemu_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3a54228..637e599 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -520,7 +520,7 @@ qemuDomainSnapshotLoad(void *payload, } while ((entry = readdir(dir))) { - if (entry->d_name[0] == '.') + if (STREQ(entry->d_name, ".") || STREQ(entry->d_name, "..")) continue; /* NB: ignoring errors, so one malformed config doesn't -- 1.8.1.1

On Mon, Jan 21, 2013 at 08:46:55PM +0100, Peter Krempa wrote:
Relax the check for the period on start of a snapshot name to skip only the '.' and '..' directories. --- src/qemu/qemu_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3a54228..637e599 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -520,7 +520,7 @@ qemuDomainSnapshotLoad(void *payload, }
while ((entry = readdir(dir))) { - if (entry->d_name[0] == '.') + if (STREQ(entry->d_name, ".") || STREQ(entry->d_name, "..")) continue;
/* NB: ignoring errors, so one malformed config doesn't
I'm not entirely convinced we should allow snapshots with a leading '.' to be created in the first place. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 01/21/2013 12:58 PM, Daniel P. Berrange wrote:
On Mon, Jan 21, 2013 at 08:46:55PM +0100, Peter Krempa wrote:
Relax the check for the period on start of a snapshot name to skip only the '.' and '..' directories. --- src/qemu/qemu_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3a54228..637e599 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -520,7 +520,7 @@ qemuDomainSnapshotLoad(void *payload, }
while ((entry = readdir(dir))) { - if (entry->d_name[0] == '.') + if (STREQ(entry->d_name, ".") || STREQ(entry->d_name, "..")) continue;
/* NB: ignoring errors, so one malformed config doesn't
I'm not entirely convinced we should allow snapshots with a leading '.' to be created in the first place.
I agree with Dan - I'd rather see a patch that goes the other direction and explicitly refuse to create a snapshot with a leading dot, just as we now explicitly refuse to create a snapshot with a slash. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 01/21/13 21:20, Eric Blake wrote:
On 01/21/2013 12:58 PM, Daniel P. Berrange wrote:
On Mon, Jan 21, 2013 at 08:46:55PM +0100, Peter Krempa wrote:
Relax the check for the period on start of a snapshot name to skip only the '.' and '..' directories. --- src/qemu/qemu_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3a54228..637e599 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -520,7 +520,7 @@ qemuDomainSnapshotLoad(void *payload, }
while ((entry = readdir(dir))) { - if (entry->d_name[0] == '.') + if (STREQ(entry->d_name, ".") || STREQ(entry->d_name, "..")) continue;
/* NB: ignoring errors, so one malformed config doesn't
I'm not entirely convinced we should allow snapshots with a leading '.' to be created in the first place.
I agree with Dan - I'd rather see a patch that goes the other direction and explicitly refuse to create a snapshot with a leading dot, just as we now explicitly refuse to create a snapshot with a slash.
I similarly don't see the reason to forbid them, but I don't care that much. Peter
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Peter Krempa