[PATCH 1/6] Fix segfault in tail(1)

From: sin <sin_AT_2f30.org>
Date: Thu, 15 Aug 2013 12:38:10 +0100

We should not be looking at optarg, that's uninitialized. We
are not using getopt.
---
 tail.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tail.c b/tail.c
index 3fbd606..037030e 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 *opt;
 
 	ARGBEGIN {
 	case 'n':
-		n = abs(estrtol(EARGF(usage()), 0));
-		if(optarg[0] == '+')
+		opt = EARGF(usage());
+		n = abs(estrtol(opt, 0));
+		if(opt[0] == '+')
 			tail = dropinit;
 		break;
 	default:
-- 
1.8.2.3
--sm4nu43k4a2Rpi4c
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="0002-Fix-warnings-about-strcpy-etc.-on-OpenBSD.patch"
Received on Mon Sep 17 2001 - 00:00:00 CEST

This archive was generated by hypermail 2.3.0 : Thu Aug 15 2013 - 14:00:09 CEST