Module Name:    src
Committed By:   kamil
Date:           Fri Aug  3 02:17:33 UTC 2018

Modified Files:
        src/external/bsd/dhcpcd/dist/src: dhcp.c

Log Message:
Fix build failure in dhcpcd under uUBSan

GCC with -fsanitize=undefiend detects a potential overflow in the code.
Cast the return value of ntohs(3) to size_t.

Fix merged upstream by <roy>.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/external/bsd/dhcpcd/dist/src/dhcp.c

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

Modified files:

Index: src/external/bsd/dhcpcd/dist/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.11 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.12
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.11	Mon Jun  4 16:45:52 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Fri Aug  3 02:17:33 2018
@@ -3267,7 +3267,7 @@ get_udp_data(void *udp, size_t *len)
 	struct bootp_pkt *p;
 
 	p = (struct bootp_pkt *)udp;
-	*len = ntohs(p->ip.ip_len) - sizeof(p->ip) - sizeof(p->udp);
+	*len = (size_t)ntohs(p->ip.ip_len) - sizeof(p->ip) - sizeof(p->udp);
 	return (char *)udp + offsetof(struct bootp_pkt, bootp);
 }
 

Reply via email to