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;
|
long n = 10;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
void (*tail)(FILE *, const char *, long) = taketail;
|
void (*tail)(FILE *, const char *, long) = taketail;
|
||||||
|
char *lines;
|
||||||
|
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
case 'n':
|
case 'n':
|
||||||
n = abs(estrtol(EARGF(usage()), 0));
|
lines = EARGF(usage());
|
||||||
if(optarg[0] == '+')
|
n = abs(estrtol(lines, 0));
|
||||||
|
if(lines[0] == '+')
|
||||||
tail = dropinit;
|
tail = dropinit;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -79,4 +81,3 @@ taketail(FILE *fp, const char *str, long n)
|
||||||
free(ring);
|
free(ring);
|
||||||
free(size);
|
free(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user