Module Name:    src
Committed By:   kamil
Date:           Wed Jul 25 23:59:08 UTC 2018

Modified Files:
        src/lib/libc/rpc: xdr_rec.c

Log Message:
Avoid undefined behavior in the definition of LAST_FRAG in xdr_rec.c

Do not change the signedness bit with a left shift operation.
Switch to unsigned integer to prevent this in the LAST_FRAG symbol.

xdr_rec.c:559:39, left shift of 1 by 31 places cannot be represented in type 
'int'
xdr_rec.c:572:26, left shift of 1 by 31 places cannot be represented in type 
'int'
xdr_rec.c:573:25, left shift of 1 by 31 places cannot be represented in type 
'int'
xdr_rec.c:632:37, left shift of 1 by 31 places cannot be represented in type 
'int'
xdr_rec.c:711:32, left shift of 1 by 31 places cannot be represented in type 
'int'
xdr_rec.c:722:28, left shift of 1 by 31 places cannot be represented in type 
'int'

Detected with micro-UBSan in the user mode.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/lib/libc/rpc/xdr_rec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/xdr_rec.c
diff -u src/lib/libc/rpc/xdr_rec.c:1.36 src/lib/libc/rpc/xdr_rec.c:1.37
--- src/lib/libc/rpc/xdr_rec.c:1.36	Thu Mar 26 11:31:57 2015
+++ src/lib/libc/rpc/xdr_rec.c	Wed Jul 25 23:59:08 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xdr_rec.c,v 1.36 2015/03/26 11:31:57 justin Exp $	*/
+/*	$NetBSD: xdr_rec.c,v 1.37 2018/07/25 23:59:08 kamil Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -37,7 +37,7 @@
 static char *sccsid = "@(#)xdr_rec.c 1.21 87/08/11 Copyr 1984 Sun Micro";
 static char *sccsid = "@(#)xdr_rec.c	2.2 88/08/01 4.0 RPCSRC";
 #else
-__RCSID("$NetBSD: xdr_rec.c,v 1.36 2015/03/26 11:31:57 justin Exp $");
+__RCSID("$NetBSD: xdr_rec.c,v 1.37 2018/07/25 23:59:08 kamil Exp $");
 #endif
 #endif
 
@@ -121,7 +121,7 @@ static const struct  xdr_ops xdrrec_ops 
  * meet the needs of xdr and rpc based on tcp.
  */
 
-#define LAST_FRAG ((uint32_t)(1 << 31))
+#define LAST_FRAG ((uint32_t)(1U << 31))
 
 typedef struct rec_strm {
 	char *tcp_handle;

Reply via email to