[PATCH] setarch: print error when command runs without arguments

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

 



$ ./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@xxxxxx>
---
 sys-utils/setarch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys-utils/setarch.c b/sys-utils/setarch.c
index 76892ab..337f8fb 100644
--- a/sys-utils/setarch.c
+++ b/sys-utils/setarch.c
@@ -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++;
-- 
2.3.0

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux