Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/inet Avoid shift of negative signed integer. this i...



details:   https://anonhg.NetBSD.org/src/rev/b7fac8287af7
branches:  trunk
changeset: 823779:b7fac8287af7
user:      maya <maya%NetBSD.org@localhost>
date:      Tue May 09 02:56:44 2017 +0000

description:
Avoid shift of negative signed integer. this is UB. NFC.

from gcc8, ok riastradh

diffstat:

 lib/libc/inet/inet_net_ntop.c |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diffs (21 lines):

diff -r db31b3362dd7 -r b7fac8287af7 lib/libc/inet/inet_net_ntop.c
--- a/lib/libc/inet/inet_net_ntop.c     Tue May 09 02:47:47 2017 +0000
+++ b/lib/libc/inet/inet_net_ntop.c     Tue May 09 02:56:44 2017 +0000
@@ -20,7 +20,7 @@
 #ifdef notdef
 static const char rcsid[] = "Id: inet_net_ntop.c,v 1.1.2.1 2002/08/02 02:17:21 marka Exp ";
 #else
-__RCSID("$NetBSD: inet_net_ntop.c,v 1.3 2012/03/20 17:08:13 matt Exp $");
+__RCSID("$NetBSD: inet_net_ntop.c,v 1.4 2017/05/09 02:56:44 maya Exp $");
 #endif
 #endif
 
@@ -199,7 +199,7 @@
                memset(inbuf + p, 0, 16 - p);
                b = bits % 8;
                if (b != 0) {
-                       m = ~0 << (8 - b);
+                       m = ~0u << (8 - b);
                        inbuf[p-1] &= m;
                }
 



Home | Main Index | Thread Index | Old Index