Skip to content

Commit 624737c

Browse files
authored
Merge pull request #12086 from donaldsharp/some_memory_backport_8.2
Some memory backport 8.2
2 parents c88537e + 3c48216 commit 624737c

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

bgpd/bgp_packet.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2440,6 +2440,14 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,
24402440
"%s CAPABILITY has action: %d, code: %u, length %u",
24412441
peer->host, action, hdr->code, hdr->length);
24422442

2443+
if (hdr->length < sizeof(struct capability_mp_data)) {
2444+
zlog_info(
2445+
"%s Capability structure is not properly filled out, expected at least %zu bytes but header length specified is %d",
2446+
peer->host, sizeof(struct capability_mp_data),
2447+
hdr->length);
2448+
return BGP_Stop;
2449+
}
2450+
24432451
/* Capability length check. */
24442452
if ((pnt + hdr->length + 3) > end) {
24452453
zlog_info("%s Capability length error", peer->host);

isisd/isis_tlvs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2966,9 +2966,9 @@ static int pack_tlv_router_cap(const struct isis_router_cap *router_cap,
29662966
}
29672967

29682968
static int unpack_tlv_router_cap(enum isis_tlv_context context,
2969-
uint8_t tlv_type, uint8_t tlv_len,
2970-
struct stream *s, struct sbuf *log,
2971-
void *dest, int indent)
2969+
uint8_t tlv_type, uint8_t tlv_len,
2970+
struct stream *s, struct sbuf *log, void *dest,
2971+
int indent)
29722972
{
29732973
struct isis_tlvs *tlvs = dest;
29742974
struct isis_router_cap *rcap;
@@ -3013,7 +3013,7 @@ static int unpack_tlv_router_cap(enum isis_tlv_context context,
30133013
log, indent,
30143014
"WARNING: Router Capability subTLV length too large compared to expected size\n");
30153015
stream_forward_getp(s, STREAM_READABLE(s));
3016-
3016+
XFREE(MTYPE_ISIS_TLV, rcap);
30173017
return 0;
30183018
}
30193019

ospfclient/ospf_apiclient.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,12 @@ int ospf_apiclient_lsa_originate(struct ospf_apiclient *oclient,
447447
return OSPF_API_ILLEGALLSATYPE;
448448
}
449449

450+
if ((size_t)opaquelen > sizeof(buf) - sizeof(struct lsa_header)) {
451+
fprintf(stderr, "opaquelen(%d) is larger than buf size %zu\n",
452+
opaquelen, sizeof(buf));
453+
return OSPF_API_NOMEMORY;
454+
}
455+
450456
/* Make a new LSA from parameters */
451457
lsah = (struct lsa_header *)buf;
452458
lsah->ls_age = 0;

0 commit comments

Comments
 (0)