Skip to content

Commit 7d23f77

Browse files
authored
Merge pull request FRRouting#19036 from FRRouting/mergify/bp/stable/10.3/pr-18994
nhrpd: fix crash when accessing invalid memory zone (backport FRRouting#18994)
2 parents ef15237 + ff7447c commit 7d23f77

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

nhrpd/nhrp_packet.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ struct nhrp_cie_header *nhrp_cie_pull(struct zbuf *zb,
182182
if (!cie)
183183
return NULL;
184184

185-
if (cie->nbma_address_len + cie->nbma_subaddress_len > 0) {
185+
if (cie->nbma_address_len + cie->nbma_subaddress_len > 0 &&
186+
cie->nbma_address_len + cie->nbma_subaddress_len <= zbuf_used(zb)) {
186187
sockunion_set(nbma, afi2family(htons(hdr->afnum)),
187188
zbuf_pulln(zb,
188189
cie->nbma_address_len
@@ -192,7 +193,7 @@ struct nhrp_cie_header *nhrp_cie_pull(struct zbuf *zb,
192193
sockunion_family(nbma) = AF_UNSPEC;
193194
}
194195

195-
if (cie->protocol_address_len) {
196+
if (cie->protocol_address_len && cie->protocol_address_len <= zbuf_used(zb)) {
196197
sockunion_set(proto, proto2family(htons(hdr->protocol_type)),
197198
zbuf_pulln(zb, cie->protocol_address_len),
198199
cie->protocol_address_len);

0 commit comments

Comments
 (0)