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/cb4d4e9e784f
branches:  trunk
changeset: 320633:cb4d4e9e784f
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 b6a1c968dfa1 -r cb4d4e9e784f 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