Project

General

Profile

Actions

Submit #3112

closed

Avoid undefined shifts in bit selector loop

Added by mmcc over 6 years ago. Updated about 6 years ago.

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 #1

Updated by eadler about 6 years ago

  • Status changed from New to Closed

Comitted in b4d0a58cfaa580afc67264c69337730c2987ebc7

Actions

Also available in: Atom PDF