]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: error if extraneous argument given
authorнаб <nabijaczleweli@nabijaczleweli.xyz>
Thu, 16 Mar 2023 16:08:59 +0000 (17:08 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 17 Mar 2023 10:46:02 +0000 (11:46 +0100)
The manual and help string both spec lsfd [options];
actually stick to that instead of ignoring subsequent arguments.

This is particularly a weird thing to allow given that lsof path
is legal and does something (either same as
lsfd -Q "MAJ:MIN == \"$(stat -c %Hd:%Ld path)\"" if it's a mountpoint or
lsfd -Q "NAME ~= '$path'" (sans the regex and escaping) otherwise).

This mirrors ec96a89ed9551ffacfc58b3056c8070444e3a2f3 for largely the
same reason.

Signed-off-by: Karel Zak <kzak@redhat.com>
Tested-by: Masatake YAMATO <yamato@redhat.com>
misc-utils/lsfd.c

index 122bef9fa824766b0aadedf561ccab2a604622fd..0337f1975caa5077e1a94db458182246dc53c471 100644 (file)
@@ -1943,6 +1943,8 @@ int main(int argc, char *argv[])
                        errtryhelp(EXIT_FAILURE);
                }
        }
+       if (argv[optind])
+               errtryhelp(EXIT_FAILURE);
 
 #define INITIALIZE_COLUMNS(COLUMN_SPEC)                                \
        for (i = 0; i < ARRAY_SIZE(COLUMN_SPEC); i++)   \