Module Name: src Committed By: bouyer Date: Sat Nov 28 15:47:05 UTC 2009
Modified Files: src/sys/net [netbsd-5]: if.c Log Message: Pull up following revision(s) (requested by joerg in ticket #1148): sys/net/if.c: revision 1.241 Simplify ifreq_setaddr: - Drop the INET6 block. The commands are never given to this function and truncating the sockaddr is arguably not the desired result anyway. - Clear the address before copying. This fixes SIOCGIFNETMASK and possible other ioctls for users that don't check sa_len. This includes COMPAT_43 and Linux emulation. OK dyoung@ To generate a diff of this commit: cvs rdiff -u -r1.230.4.1 -r1.230.4.2 src/sys/net/if.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/net/if.c diff -u src/sys/net/if.c:1.230.4.1 src/sys/net/if.c:1.230.4.2 --- src/sys/net/if.c:1.230.4.1 Tue Feb 24 02:26:42 2009 +++ src/sys/net/if.c Sat Nov 28 15:47:05 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: if.c,v 1.230.4.1 2009/02/24 02:26:42 snj Exp $ */ +/* $NetBSD: if.c,v 1.230.4.2 2009/11/28 15:47:05 bouyer Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc. @@ -90,7 +90,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.230.4.1 2009/02/24 02:26:42 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.230.4.2 2009/11/28 15:47:05 bouyer Exp $"); #include "opt_inet.h" @@ -1816,20 +1816,14 @@ { uint8_t len; u_long ncmd; - const uint8_t osockspace = sizeof(ifr->ifr_addr); - const uint8_t sockspace = sizeof(ifr->ifr_ifru.ifru_space); -#ifdef INET6 - if (cmd == SIOCGIFPSRCADDR_IN6 || cmd == SIOCGIFPDSTADDR_IN6) - len = MIN(sizeof(struct sockaddr_in6), sa->sa_len); - else -#endif /* INET6 */ if ((ncmd = compat_cvtcmd(cmd)) != cmd) - len = MIN(osockspace, sa->sa_len); + len = sizeof(ifr->ifr_addr); else - len = MIN(sockspace, sa->sa_len); + len = sizeof(ifr->ifr_ifru.ifru_space); if (len < sa->sa_len) return EFBIG; + memset(&ifr->ifr_addr, 0, len); sockaddr_copy(&ifr->ifr_addr, len, sa); return 0; }