[hackers] [sbase] Fix segfault in tail(1) || sin

From: <git_AT_suckless.org>
Date: Sat, 05 Oct 2013 16:29:14 +0200

commit 7d4d519a5166acd852de68c3bfc442289d091b25
Author: sin <sin_AT_2f30.org>
Date: Sat Aug 31 21:53:11 2013 +0100

    Fix segfault in tail(1)
    
    We should not be looking at optarg, that's uninitialized. We
    are not using getopt.

diff --git a/tail.c b/tail.c
index 3fbd606..e45d924 100644
--- a/tail.c
+++ b/tail.c
_AT_@ -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:
_AT_@ -79,4 +81,3 @@ taketail(FILE *fp, const char *str, long n)
         free(ring);
         free(size);
 }
-
Received on Sat Oct 05 2013 - 16:29:14 CEST

This archive was generated by hypermail 2.3.0 : Sat Oct 05 2013 - 16:36:14 CEST