Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Sep 2020 12:54:42 +0000 (UTC)
From:      Alex Richardson <arichardson@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r366075 - head/contrib/byacc
Message-ID:  <202009231254.08NCsgWI097069@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: arichardson
Date: Wed Sep 23 12:54:42 2020
New Revision: 366075
URL: https://svnweb.freebsd.org/changeset/base/366075

Log:
  byacc: fix UBSan signed shift range error
  
  I've submitted this patch upstream, so apply this to contrib/ until a new
  version containing this change has been released.
  
  Reviewed By:	jkim
  Differential Revision: https://reviews.freebsd.org/D26505

Modified:
  head/contrib/byacc/closure.c
  head/contrib/byacc/warshall.c

Modified: head/contrib/byacc/closure.c
==============================================================================
--- head/contrib/byacc/closure.c	Wed Sep 23 12:54:37 2020	(r366074)
+++ head/contrib/byacc/closure.c	Wed Sep 23 12:54:42 2020	(r366075)
@@ -87,7 +87,7 @@ set_first_derives(void)
 		k = 0;
 	    }
 
-	    if (cword & (unsigned)(1 << k))
+	    if (cword & (1u << k))
 	    {
 		rp = derives[j];
 		while ((rule = *rp++) >= 0)
@@ -151,7 +151,7 @@ closure(Value_t *nucleus, int n)
 	{
 	    for (i = 0; i < BITS_PER_WORD; ++i)
 	    {
-		if (word & (unsigned)(1 << i))
+		if (word & (1u << i))
 		{
 		    itemno = rrhs[ruleno + i];
 		    while (csp < csend && *csp < itemno)

Modified: head/contrib/byacc/warshall.c
==============================================================================
--- head/contrib/byacc/warshall.c	Wed Sep 23 12:54:37 2020	(r366074)
+++ head/contrib/byacc/warshall.c	Wed Sep 23 12:54:42 2020	(r366075)
@@ -28,7 +28,7 @@ transitive_closure(unsigned *R, int n)
 
 	while (rowj < relend)
 	{
-	    if (*ccol & (unsigned)(1 << i))
+	    if (*ccol & (1u << i))
 	    {
 		rp = rowi;
 		rend = rowj + rowsize;
@@ -70,7 +70,7 @@ reflexive_transitive_closure(unsigned *R, int n)
     rp = R;
     while (rp < relend)
     {
-	*rp |= (unsigned)(1 << i);
+	*rp |= (1u << i);
 	if (++i >= BITS_PER_WORD)
 	{
 	    i = 0;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202009231254.08NCsgWI097069>