Source-Changes-HG archive

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

[src/trunk]: src/sys/net Use unsigned to avoid undefined behavior. Found by k...



details:   https://anonhg.NetBSD.org/src/rev/21b0690e169b
branches:  trunk
changeset: 1027611:21b0690e169b
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Mon Dec 13 02:53:43 2021 +0000

description:
Use unsigned to avoid undefined behavior. Found by kUBSan.

Reported-by: syzbot+699ce32cd32e2a670788%syzkaller.appspotmail.com@localhost

diffstat:

 sys/net/ppp_tty.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (36 lines):

diff -r c0ee6c635606 -r 21b0690e169b sys/net/ppp_tty.c
--- a/sys/net/ppp_tty.c Mon Dec 13 02:34:15 2021 +0000
+++ b/sys/net/ppp_tty.c Mon Dec 13 02:53:43 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ppp_tty.c,v 1.68 2021/09/27 07:13:30 msaitoh Exp $     */
+/*     $NetBSD: ppp_tty.c,v 1.69 2021/12/13 02:53:43 msaitoh Exp $     */
 /*     Id: ppp_tty.c,v 1.3 1996/07/01 01:04:11 paulus Exp      */
 
 /*
@@ -93,7 +93,7 @@
 /* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ppp_tty.c,v 1.68 2021/09/27 07:13:30 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ppp_tty.c,v 1.69 2021/12/13 02:53:43 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "ppp.h"
@@ -1008,7 +1008,7 @@
        sc->sc_flags |= SC_RCV_B7_1;
     else
        sc->sc_flags |= SC_RCV_B7_0;
-    if (paritytab[c >> 5] & (1 << (c & 0x1F)))
+    if (paritytab[c >> 5] & (1U << (c & 0x1F)))
        sc->sc_flags |= SC_RCV_ODDP;
     else
        sc->sc_flags |= SC_RCV_EVNP;
@@ -1089,7 +1089,7 @@
        return 0;
     }
 
-    if (c < 0x20 && (sc->sc_rasyncmap & (1 << c)))
+    if (c < 0x20 && (sc->sc_rasyncmap & (1U << c)))
        return 0;
 
     s = spltty();



Home | Main Index | Thread Index | Old Index