[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Linphone-developers] [belle-sip PATCH 1/2] Fix undefined shift to unrep
From: |
James Cowgill |
Subject: |
[Linphone-developers] [belle-sip PATCH 1/2] Fix undefined shift to unrepresentable value in dns.c |
Date: |
Mon, 7 Dec 2015 20:50:46 +0000 |
If the top bit of P->data[rr->rd.p] is set, the shifted value will not fit into
an int which is undefined behavior. Fix by forcing the left hand side of the
shift to be promoted to an unsigned int first.
---
src/dns.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/dns.c b/src/dns.c
index 70826cb..789c39f 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -2401,10 +2401,10 @@ int dns_a_parse(struct dns_a *a, struct dns_rr *rr,
struct dns_packet *P) {
if (rr->rd.len != 4)
return DNS_EILLEGAL;
- addr = ((0xff & P->data[rr->rd.p + 0]) << 24)
- | ((0xff & P->data[rr->rd.p + 1]) << 16)
- | ((0xff & P->data[rr->rd.p + 2]) << 8)
- | ((0xff & P->data[rr->rd.p + 3]) << 0);
+ addr = ((0xffU & P->data[rr->rd.p + 0]) << 24)
+ | ((0xffU & P->data[rr->rd.p + 1]) << 16)
+ | ((0xffU & P->data[rr->rd.p + 2]) << 8)
+ | ((0xffU & P->data[rr->rd.p + 3]) << 0);
a->addr.s_addr = htonl(addr);
--
2.6.2