From b5b5ac32372c19b0776dceec67c9ed876b8616d3 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Fri, 28 Mar 2003 16:54:14 +0000 Subject: trivial fix to make sure we have sufficient arguments before we mess with a possibly non-existant argv[1] -Erik --- coreutils/tail.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'coreutils') diff --git a/coreutils/tail.c b/coreutils/tail.c index 8e0adf5..10b5cd7 100644 --- a/coreutils/tail.c +++ b/coreutils/tail.c @@ -118,11 +118,10 @@ int tail_main(int argc, char **argv) const char *fmt; /* Allow legacy syntax of an initial numeric option without -n. */ - if ((argv[1][0] == '+') - || ((argv[1][0] == '-') + if (argc >=2 && ((argv[1][0] == '+') || ((argv[1][0] == '-') /* && (isdigit)(argv[1][1]) */ - && (((unsigned int)(argv[1][1] - '0')) <= 9)) - ) { + && (((unsigned int)(argv[1][1] - '0')) <= 9)))) + { optind = 2; optarg = argv[1]; goto GET_COUNT; -- cgit v1.1