sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

commit 7d4d519a5166acd852de68c3bfc442289d091b25
parent fd262561a946c74885cd8b3fa42bd4a41f1c0d82
Author: sin <sin@2f30.org>
Date:   Sat Aug 31 21:53:11 +0100

Fix segfault in tail(1)

We should not be looking at optarg, that's uninitialized.  We
are not using getopt.

Diffstat:
tail.c | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tail.c b/tail.c @@ -21,11 +21,13 @@ main(int argc, char *argv[]) long n = 10; FILE *fp; void (*tail)(FILE *, const char *, long) = taketail; + char *lines; ARGBEGIN { case 'n': - n = abs(estrtol(EARGF(usage()), 0)); - if(optarg[0] == '+') + lines = EARGF(usage()); + n = abs(estrtol(lines, 0)); + if(lines[0] == '+') tail = dropinit; break; default: @@ -79,4 +81,3 @@ taketail(FILE *fp, const char *str, long n) free(ring); free(size); } -