Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/tprof Fix a crash when running tprof with no argume...



details:   https://anonhg.NetBSD.org/src/rev/377ac35ba564
branches:  trunk
changeset: 363177:377ac35ba564
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Jul 14 16:34:15 2018 +0000

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

diffstat:

 usr.sbin/tprof/tprof.c |  7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diffs (28 lines):

diff -r 0d28f04e6c5d -r 377ac35ba564 usr.sbin/tprof/tprof.c
--- a/usr.sbin/tprof/tprof.c    Sat Jul 14 15:38:59 2018 +0000
+++ b/usr.sbin/tprof/tprof.c    Sat Jul 14 16:34:15 2018 +0000
@@ -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 @@
                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 &&



Home | Main Index | Thread Index | Old Index