setarch: print error when command runs without arguments

$ ./setarch
Segmentation fault (core dumped)
$ coredumpctl gdb
...
Program terminated with signal SIGSEGV, Segmentation fault.
301                     if (*argv[1] != '-') {

Reference: 5edb0ea6bb
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2015-02-17 22:31:48 +00:00 committed by Karel Zak
parent 0209a128b5
commit 00b5ef70e2

View 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++;