aboutsummaryrefslogtreecommitdiff
path: root/coreutils/head.c
diff options
context:
space:
mode:
authorJohn Beppu <beppu@lbox.org>1999-12-15 19:29:09 +0000
committerJohn Beppu <beppu@lbox.org>1999-12-15 19:29:09 +0000
commit25ab6534576eb0dbb636867ff992ab3a69ae06bc (patch)
treee581f37fa8f12f4e756fed152294f9c3212ab5e6 /coreutils/head.c
parente1618e42a8299cc928ba9af78bbea65899e76f4b (diff)
downloadbusybox-w32-25ab6534576eb0dbb636867ff992ab3a69ae06bc.tar.gz
busybox-w32-25ab6534576eb0dbb636867ff992ab3a69ae06bc.tar.bz2
busybox-w32-25ab6534576eb0dbb636867ff992ab3a69ae06bc.zip
fixed an embarrasing segfault (head w/ no args
used to die (but now it lives))
Diffstat (limited to 'coreutils/head.c')
-rw-r--r--coreutils/head.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/coreutils/head.c b/coreutils/head.c
index 23adce79f..a9d024e62 100644
--- a/coreutils/head.c
+++ b/coreutils/head.c
@@ -54,7 +54,7 @@ head_main(int argc, char **argv)
54 int len = 10; 54 int len = 10;
55 55
56 /* 1st option is potentially special */ 56 /* 1st option is potentially special */
57 if ((argv[1][0] == '-') && isDecimal(argv[1][1])) { 57 if ((argc > 1) && (argv[1][0] == '-') && isDecimal(argv[1][1])) {
58 int tmplen = atoi(&argv[1][1]); 58 int tmplen = atoi(&argv[1][1]);
59 if (tmplen) { len = tmplen; } 59 if (tmplen) { len = tmplen; }
60 i = 2; 60 i = 2;
@@ -66,6 +66,7 @@ head_main(int argc, char **argv)
66 opt = argv[i][1]; 66 opt = argv[i][1];
67 switch (opt) { 67 switch (opt) {
68 case '-': 68 case '-':
69 break;
69 case 'h': 70 case 'h':
70 usage(head_usage); 71 usage(head_usage);
71 default: 72 default:
@@ -103,4 +104,4 @@ head_main(int argc, char **argv)
103 exit(0); 104 exit(0);
104} 105}
105 106
106/* $Id: head.c,v 1.2 1999/12/10 08:29:20 andersen Exp $ */ 107/* $Id: head.c,v 1.3 1999/12/15 19:29:09 beppu Exp $ */