[DragonFlyBSD - Submit #3112] (Closed) Avoid undefined shifts in bit selector loop

bugtracker-admin at leaf.dragonflybsd.org bugtracker-admin at leaf.dragonflybsd.org
Sat Jan 27 21:36:01 PST 2018


Issue #3112 has been updated by eadler.

Status changed from New to Closed

Comitted in b4d0a58cfaa580afc67264c69337730c2987ebc7

----------------------------------------
Submit #3112: Avoid undefined shifts in bit selector loop
http://bugs.dragonflybsd.org/issues/3112#change-13374

* Author: mmcc
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
----------------------------------------
Hi guys.

I fixed this issue in OpenBSD a while back, but I figured I should check and
inform the rest of the BSDs.

Shifting into or out of an int's sign bit is undefined, and this loop
deterministically and intentionally does both. The following change
was applied to OpenBSD and (IIRC) NetBSD.

Thanks for your time,
Michael McConville

diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 8145d9e052..5930a462f2 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -108,7 +108,7 @@ int
findproto(char *cp, int n)
{
	struct sockaddr *sa;
-	int i;
+	unsigned int i;

	if (n == 0)
		return -1;



-- 
You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://bugs.dragonflybsd.org/my/account



More information about the Submit mailing list