Actions
Submit #3112
closedAvoid undefined shifts in bit selector loop
Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
12/12/2017
Due date:
% Done:
0%
Estimated time:
Description
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;
Actions