]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
setarch: print error when command runs without arguments
authorSami Kerola <kerolasa@iki.fi>
Tue, 17 Feb 2015 22:31:48 +0000 (22:31 +0000)
committerKarel Zak <kzak@redhat.com>
Thu, 19 Feb 2015 09:55:10 +0000 (10:55 +0100)
$ ./setarch
Segmentation fault (core dumped)
$ coredumpctl gdb
...
Program terminated with signal SIGSEGV, Segmentation fault.
301                     if (*argv[1] != '-') {

Reference: 5edb0ea6bbd57dd916417737f98c9109dc1ecb5b
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sys-utils/setarch.c

index 76892ab4fe3a8e42ae19f79bb825598d3dc6b1b9..337f8fbaf9f2766a863f58536f046b4fec4af69d 100644 (file)
@@ -298,7 +298,7 @@ int main(int argc, char *argv[])
        if (archwrapper)
                arch = program_invocation_short_name;   /* symlinks to setarch */
        else {
-               if (*argv[1] != '-') {
+               if (1 < argc && *argv[1] != '-') {
                        arch = argv[1];
                        argv[1] = argv[0];      /* for getopt_long() to get the program name */
                        argv++;