]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
losetup: keep -f and <devname> mutually exclusive
authorKarel Zak <kzak@redhat.com>
Thu, 7 Jun 2018 10:05:08 +0000 (12:05 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 7 Jun 2018 10:05:08 +0000 (12:05 +0200)
losetup tries to blindly use specified device as well as search for
the first free device, the result is:

 # losetup /dev/loop1 -f /tmp/tfile_loop1
 losetup: /dev/loop1: failed to set up loop device: Invalid argument

fixed version:

 # losetup /dev/loop10 -f img
 losetup: unexpected arguments

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1566432
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/losetup.c

index 670bce2e393803a8c7fe12956ae8d1d45de8baf9..9eecf06a4cace3e1c568e98fa2cbee7cd3f311a0 100644 (file)
@@ -762,6 +762,9 @@ int main(int argc, char **argv)
                 */
                act = A_CREATE;
                file = argv[optind++];
+
+               if (optind < argc)
+                       errx(EXIT_FAILURE, _("unexpected arguments"));
        }
 
        if (list && !act && optind == argc)