Source-Changes-HG archive

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

[src/trunk]: src/sys/net Adjust prior to enforce minimum socket length includ...



details:   https://anonhg.NetBSD.org/src/rev/17bc6bc0d9a4
branches:  trunk
changeset: 973294:17bc6bc0d9a4
user:      roy <roy%NetBSD.org@localhost>
date:      Fri Jun 26 15:53:59 2020 +0000

description:
Adjust prior to enforce minimum socket length includes sa_family

Not that the code strictly needs it, but if the macro is ever used
elsewhere then it makes sense as every sockaddr must have it.
The rest of the structure is dictated by the family and in some cases,
truncated on purpose so this is fine.

diffstat:

 sys/net/rtsock_shared.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (30 lines):

diff -r 5af5743d51ce -r 17bc6bc0d9a4 sys/net/rtsock_shared.c
--- a/sys/net/rtsock_shared.c   Fri Jun 26 15:46:28 2020 +0000
+++ b/sys/net/rtsock_shared.c   Fri Jun 26 15:53:59 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtsock_shared.c,v 1.18 2020/06/24 12:27:51 roy Exp $   */
+/*     $NetBSD: rtsock_shared.c,v 1.19 2020/06/26 15:53:59 roy Exp $   */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock_shared.c,v 1.18 2020/06/24 12:27:51 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock_shared.c,v 1.19 2020/06/26 15:53:59 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -96,8 +96,9 @@
 #include <compat/net/if.h>
 #include <compat/net/route.h>
 
-#define _SA_MINSIZE    (offsetof(struct sockaddr, sa_len) + \
-                        sizeof(((struct sockaddr *)0)->sa_len))
+/* sa_family is after sa_len, rest is data */
+#define _SA_MINSIZE    (offsetof(struct sockaddr, sa_family) + \
+                        sizeof(((struct sockaddr *)0)->sa_family))
 
 #ifdef COMPAT_RTSOCK
 /*



Home | Main Index | Thread Index | Old Index