Source-Changes-HG archive

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

[src/trunk]: src/external/bsd/ipf/dist use target size in a couple of strncpy...



details:   https://anonhg.NetBSD.org/src/rev/904b81818382
branches:  trunk
changeset: 1003953:904b81818382
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sat Oct 05 23:32:20 2019 +0000

description:
use target size in a couple of strncpy() calls:
- load_hash() has already zeroed the structure so final nul is there.
- print_ipflog() copied final byte that was then nul'd.

diffstat:

 external/bsd/ipf/dist/lib/load_hash.c |  6 +++---
 external/bsd/ipf/dist/tools/ipmon.c   |  4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diffs (38 lines):

diff -r b5e29c39d7e4 -r 904b81818382 external/bsd/ipf/dist/lib/load_hash.c
--- a/external/bsd/ipf/dist/lib/load_hash.c     Sat Oct 05 23:30:22 2019 +0000
+++ b/external/bsd/ipf/dist/lib/load_hash.c     Sat Oct 05 23:32:20 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: load_hash.c,v 1.2 2012/07/22 14:27:36 darrenr Exp $    */
+/*     $NetBSD: load_hash.c,v 1.3 2019/10/05 23:32:20 mrg Exp $        */
 
 /*
  * Copyright (C) 2012 by Darren Reed.
@@ -67,8 +67,8 @@
                        }
        }
 
-       strncpy(iph.iph_name, op.iplo_name, sizeof(op.iplo_name));
-       strncpy(iphp->iph_name, op.iplo_name, sizeof(op.iplo_name));
+       strncpy(iph.iph_name, op.iplo_name, sizeof(iph.iph_name) - 1);
+       strncpy(iphp->iph_name, op.iplo_name, sizeof(iphp->iph_name) - 1);
 
        if (opts & OPT_VERBOSE) {
                iph.iph_table = calloc(size, sizeof(*iph.iph_table));
diff -r b5e29c39d7e4 -r 904b81818382 external/bsd/ipf/dist/tools/ipmon.c
--- a/external/bsd/ipf/dist/tools/ipmon.c       Sat Oct 05 23:30:22 2019 +0000
+++ b/external/bsd/ipf/dist/tools/ipmon.c       Sat Oct 05 23:32:20 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipmon.c,v 1.8 2018/02/04 08:19:42 mrg Exp $    */
+/*     $NetBSD: ipmon.c,v 1.9 2019/10/05 23:32:20 mrg Exp $    */
 
 /*
  * Copyright (C) 2012 by Darren Reed.
@@ -1097,7 +1097,7 @@
        {
        char    ifname[sizeof(ipf.fl_ifname) + 1];
 
-       strncpy(ifname, ipf.fl_ifname, sizeof(ipf.fl_ifname));
+       strncpy(ifname, ipf.fl_ifname, sizeof(ifname)-1);
        ifname[sizeof(ipf.fl_ifname)] = '\0';
        sprintf(t, "%s", ifname);
        t += strlen(t);



Home | Main Index | Thread Index | Old Index