Source-Changes-HG archive

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

[src/trunk]: src/sys/net Cast uint32_t to avoid undefined behavior in bridge_...



details:   https://anonhg.NetBSD.org/src/rev/db7278a29537
branches:  trunk
changeset: 964504:db7278a29537
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Mon Aug 05 13:30:21 2019 +0000

description:
Cast uint32_t to avoid undefined behavior in bridge_rthash(). Found by kUBSan.

diffstat:

 sys/net/if_bridge.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 65360ebb17ae -r db7278a29537 sys/net/if_bridge.c
--- a/sys/net/if_bridge.c       Mon Aug 05 13:28:31 2019 +0000
+++ b/sys/net/if_bridge.c       Mon Aug 05 13:30:21 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_bridge.c,v 1.164 2018/12/22 04:28:30 rin Exp $      */
+/*     $NetBSD: if_bridge.c,v 1.165 2019/08/05 13:30:21 msaitoh Exp $  */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.164 2018/12/22 04:28:30 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.165 2019/08/05 13:30:21 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_bridge_ipf.h"
@@ -2517,7 +2517,7 @@
 
        b += addr[5] << 8;
        b += addr[4];
-       a += addr[3] << 24;
+       a += (uint32_t)addr[3] << 24;
        a += addr[2] << 16;
        a += addr[1] << 8;
        a += addr[0];



Home | Main Index | Thread Index | Old Index