Fix segfault in tail(1)
We should not be looking at optarg, that's uninitialized. We are not using getopt.
This commit is contained in:
parent
fd262561a9
commit
7d4d519a51
7
tail.c
7
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user