[relay]: Prevent Buffer Overrun Of Malformed DHCP Packet (#6057)

[dhcp-relay]: Prevent Buffer Overrun Of Malformed DHCP Packet

The add/strip relay agent options does not take into account the buffer
length and so it is possible to overrun the buffer. The issue will
result in contents from previous packet being added to the current one.

signed-off-by: Tamer Ahmed <tamer.ahmed@microsoft.com>
This commit is contained in:
Tamer Ahmed 2020-12-11 16:28:05 -08:00 committed by GitHub
parent 6999ce5282
commit cbbda09599
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,30 @@
From 19e400c1040e3621db6a0d8dd70d18c431d1a848 Mon Sep 17 00:00:00 2001
From: Tamer Ahmed <tamer.ahmed@microsoft.com>
Date: Sat, 28 Nov 2020 16:28:37 -0800
Subject: [PATCH] [dhcp-relay] Prevent Buffer Overrun
The add/strip relay agent options do not take into account the buffer
length and so it is possible to overrun the buffer. The issue will
result in contents from previous packet being added to the current one.
signed-off-by: Tamer Ahmed <tamer.ahmed@microsoft.com>
---
relay/dhcrelay.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c
index 055d97f..1cd99b9 100644
--- a/relay/dhcrelay.c
+++ b/relay/dhcrelay.c
@@ -1527,7 +1527,7 @@ add_relay_agent_options(struct interface_info *ip, struct dhcp_packet *packet,
/* Commence processing after the cookie. */
sp = op = &packet->options[4];
- while (op < max) {
+ while ((op < max) && (op < (((u_int8_t *)packet) + length))) {
switch(*op) {
/* Skip padding... */
case DHO_PAD:
--
2.17.1

View File

@ -9,3 +9,4 @@
0008-Don-t-skip-down-interfaces-when-discovering-interfac.patch
0009-Support-for-dual-tor-scenario.patch
0010-Bugfix-correctly-set-interface-netmask.patch
0011-dhcp-relay-Prevent-Buffer-Overrun.patch