Source-Changes-HG archive

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

[src/netbsd-10]: src/usr.sbin/tprof Pull up following revision(s) (requested ...



details:   https://anonhg.NetBSD.org/src/rev/d043e95bee2c
branches:  netbsd-10
changeset: 372766:d043e95bee2c
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Dec 24 17:17:27 2022 +0000

description:
Pull up following revision(s) (requested by christos in ticket #22):

        usr.sbin/tprof/tprof_top.c: revision 1.8

use malloc instead of alloca so that SSP works.

diffstat:

 usr.sbin/tprof/tprof_top.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (45 lines):

diff -r 1216ed2cf16e -r d043e95bee2c usr.sbin/tprof/tprof_top.c
--- a/usr.sbin/tprof/tprof_top.c        Sat Dec 24 09:27:51 2022 +0000
+++ b/usr.sbin/tprof/tprof_top.c        Sat Dec 24 17:17:27 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tprof_top.c,v 1.7 2022/12/16 08:02:04 ryo Exp $        */
+/*     $NetBSD: tprof_top.c,v 1.7.2.1 2022/12/24 17:17:27 martin Exp $ */
 
 /*-
  * Copyright (c) 2022 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: tprof_top.c,v 1.7 2022/12/16 08:02:04 ryo Exp $");
+__RCSID("$NetBSD: tprof_top.c,v 1.7.2.1 2022/12/24 17:17:27 martin Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -194,7 +194,9 @@
        if (*lim <= 0)
                return 0;
 
-       p = alloca(*lim + 1);
+       p = malloc(*lim + 1);
+       if (p == NULL)
+               return -1;
 
        va_start(ap, fmt);
        vsnprintf(p, *lim + 1, fmt, ap);
@@ -202,6 +204,7 @@
 
        written = strlen(p);
        if (written == 0) {
+               free(p);
                *lim = 0;
                return 0;
        }
@@ -209,6 +212,7 @@
        fwrite(p, written, 1, stdout);
        *lim -= written;
 
+       free(p);
        return written;
 }
 



Home | Main Index | Thread Index | Old Index