Skip to contentSkip to conversation

dhcp-transport: fix out-of-bounds access

PATCH Applied James Prestwood 2 participants 2 messages Aug 6, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dhcp-transport: fix out-of-bounds access

If len was odd the iovec was getting accessed out of bounds. 'j' needed to be decremented after the for loop. In addition, the iov_len was not being used to access the last byte of iov_base.

---
 ell/dhcp-transport.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
ell/dhcp-transport.c +3 -1
index b43dfbd..56db9dd 100644
@@ -78,9 +78,11 @@ uint16_t _dhcp_checksumv(const struct iovec *iov, size_t iov_cnt)
 			sum += check[i];
 	}
 
+	j--;
+
 	if (len & 0x01) {
 		const uint8_t *odd = iov[j].iov_base;
-		sum += odd[len - 1];
+		sum += odd[iov[j].iov_len - 1];
 	}
 
 	while (sum >> 16)
Signature · 1 line
2.21.0
#1 lore raw

Hi James,

Quoted 6 lines · James Prestwood

If len was odd the iovec was getting accessed out of bounds. 'j' needed to be decremented after the for loop. In addition, the iov_len was not being used to access the last byte of iov_base.

---
  ell/dhcp-transport.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

Applied, thanks.

Regards,
-Denis