1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-30 06:25:37 +03:00

libsystemd-network: refuse too large raw_size

Closes #23258.
This commit is contained in:
Yu Watanabe 2022-05-04 15:45:13 +09:00
parent fa2ba7aea8
commit 4e88a46bfe
2 changed files with 6 additions and 0 deletions

View File

@ -116,6 +116,9 @@ sd_lldp_neighbor *lldp_neighbor_unlink(sd_lldp_neighbor *n) {
sd_lldp_neighbor *lldp_neighbor_new(size_t raw_size) {
sd_lldp_neighbor *n;
if (raw_size > SIZE_MAX - ALIGN(sizeof(sd_lldp_neighbor)))
return NULL;
n = malloc0(ALIGN(sizeof(sd_lldp_neighbor)) + raw_size);
if (!n)
return NULL;

View File

@ -21,6 +21,9 @@ DEFINE_PUBLIC_TRIVIAL_REF_UNREF_FUNC(sd_ndisc_router, sd_ndisc_router, mfree);
sd_ndisc_router *ndisc_router_new(size_t raw_size) {
sd_ndisc_router *rt;
if (raw_size > SIZE_MAX - ALIGN(sizeof(sd_ndisc_router)))
return NULL;
rt = malloc0(ALIGN(sizeof(sd_ndisc_router)) + raw_size);
if (!rt)
return NULL;