qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Prevent overriding the input file with the output file


From: Eric Blake
Subject: Re: [Qemu-devel] Prevent overriding the input file with the output file when using qemu-img
Date: Tue, 23 Jan 2018 08:48:15 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2

On 01/22/2018 10:40 PM, River Chiang wrote:
>     Signed-off-by: River Chiang <address@hidden>
> 
> ---------------------------------- qemu-img.c
> ----------------------------------
> index 68b375f998..5ce594ea00 100644
> @@ -2098,6 +2098,9 @@ static int img_convert(int argc, char **argv)
>      if (s.src_num < 1) {
>          error_report("Must specify image file name");
>          goto fail_getopt;
> +    } else if (!strcmp(argv[optind], out_filename)) {
> +        error_report("Override the input file with the output file");
> +        goto fail_getopt;

Comparing names is too prone to false negatives.  'foo' and './foo' are
the same file, but your test won't catch it.  Better might be checking
if stat() reports the same dev/inode pair for the two files.

By the way, your patch is not in proper 'git send-email' format, which
makes it hard to test whether it even applies.  More patch submission
hints at http://wiki.qemu.org/Contribute/SubmitAPatch

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]