Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/netbsd32 Don't use strlcpy to copy untrusted inpu...



details:   https://anonhg.NetBSD.org/src/rev/434e3ab1b603
branches:  trunk
changeset: 969183:434e3ab1b603
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Mon Feb 10 22:33:28 2020 +0000

description:
Don't use strlcpy to copy untrusted input, it may not be NUL-terminated.

diffstat:

 sys/compat/netbsd32/netbsd32_ioctl.c |  16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diffs (72 lines):

diff -r 28ceb12857b9 -r 434e3ab1b603 sys/compat/netbsd32/netbsd32_ioctl.c
--- a/sys/compat/netbsd32/netbsd32_ioctl.c      Mon Feb 10 22:13:50 2020 +0000
+++ b/sys/compat/netbsd32/netbsd32_ioctl.c      Mon Feb 10 22:33:28 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_ioctl.c,v 1.107 2020/02/01 02:23:03 riastradh Exp $   */
+/*     $NetBSD: netbsd32_ioctl.c,v 1.108 2020/02/10 22:33:28 mlelstv Exp $     */
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.107 2020/02/01 02:23:03 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.108 2020/02/10 22:33:28 mlelstv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ntp.h"
@@ -147,7 +147,7 @@
     struct if_addrprefreq *ifap, u_long cmd)
 {
 
-       strlcpy(ifap->ifap_name, ifap32->ifap_name, sizeof(ifap->ifap_name));
+       memcpy(ifap->ifap_name, ifap32->ifap_name, IFNAMSIZ+1);
        ifap->ifap_preference = ifap32->ifap_preference;
        memcpy(&ifap->ifap_addr, &ifap32->ifap_addr,
            uimin(ifap32->ifap_addr.ss_len, _SS_MAXSIZE));
@@ -386,7 +386,7 @@
     struct ieee80211req *ireq, u_long cmd)
 {
 
-       strlcpy(ireq->i_name, ireq32->i_name, IFNAMSIZ);
+       memcpy(ireq->i_name, ireq32->i_name, IFNAMSIZ);
        ireq->i_type = ireq32->i_type;
        ireq->i_val = ireq32->i_val;
        ireq->i_len = ireq32->i_len;
@@ -399,7 +399,7 @@
 {
        int i;
 
-       strlcpy(nwk->i_name, nwk32->i_name, IFNAMSIZ);
+       memcpy(nwk->i_name, nwk32->i_name, IFNAMSIZ);
        nwk->i_wepon = nwk32->i_wepon;
        nwk->i_defkid = nwk32->i_defkid;
        for (i = 0; i < IEEE80211_WEP_NKID; i++) {
@@ -630,7 +630,7 @@
     struct netbsd32_if_addrprefreq *ifap32, u_long cmd)
 {
 
-       strlcpy(ifap32->ifap_name, ifap->ifap_name, sizeof(ifap32->ifap_name));
+       memcpy(ifap32->ifap_name, ifap->ifap_name, IFNAMSIZ);
        ifap32->ifap_preference = ifap->ifap_preference;
        memcpy(&ifap32->ifap_addr, &ifap->ifap_addr,
            uimin(ifap->ifap_addr.ss_len, _SS_MAXSIZE));
@@ -865,7 +865,7 @@
     struct netbsd32_ieee80211req *ireq32, u_long cmd)
 {
 
-       strlcpy(ireq32->i_name, ireq->i_name, IFNAMSIZ);
+       memcpy(ireq32->i_name, ireq->i_name, IFNAMSIZ);
        ireq32->i_type = ireq->i_type;
        ireq32->i_val = ireq->i_val;
        ireq32->i_len = ireq->i_len;
@@ -878,7 +878,7 @@
 {
        int i;
 
-       strlcpy(nwk32->i_name, nwk->i_name, IFNAMSIZ);
+       memcpy(nwk32->i_name, nwk->i_name, IFNAMSIZ);
        nwk32->i_wepon = nwk->i_wepon;
        nwk32->i_defkid = nwk->i_defkid;
        for (i = 0; i < IEEE80211_WEP_NKID; i++) {



Home | Main Index | Thread Index | Old Index