Module Name:    src
Committed By:   jmcneill
Date:           Sat Jul 14 16:34:15 UTC 2018

Modified Files:
        src/usr.sbin/tprof: tprof.c

Log Message:
Fix a crash when running tprof with no arguments; check argc before accessing 
argv[0]


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/tprof/tprof.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/tprof/tprof.c
diff -u src/usr.sbin/tprof/tprof.c:1.10 src/usr.sbin/tprof/tprof.c:1.11
--- src/usr.sbin/tprof/tprof.c:1.10	Fri Jul 13 19:54:53 2018
+++ src/usr.sbin/tprof/tprof.c	Sat Jul 14 16:34:15 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tprof.c,v 1.10 2018/07/13 19:54:53 joerg Exp $	*/
+/*	$NetBSD: tprof.c,v 1.11 2018/07/14 16:34:15 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: tprof.c,v 1.10 2018/07/13 19:54:53 joerg Exp $");
+__RCSID("$NetBSD: tprof.c,v 1.11 2018/07/14 16:34:15 jmcneill Exp $");
 #endif /* not lint */
 
 #include <sys/ioctl.h>
@@ -287,6 +287,9 @@ main(int argc, char *argv[])
 		err(EXIT_FAILURE, "cpu not supported");
 	}
 
+	if (argc == 0)
+		usage();
+
 	for (ct = tprof_cmdtab; ct->label != NULL; ct++) {
 		if (strcmp(argv[0], ct->label) == 0) {
 			if (!ct->argsoptional &&

Reply via email to