From c237e0b558fa6ae2a1417f4b4df14212b8721ba8 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 25 Sep 2025 22:59:23 -0400 Subject: link: Add NULL checks Signed-off-by: Ian Moffett --- src/dgram/dgram_link.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/dgram/dgram_link.c b/src/dgram/dgram_link.c index 145e716..c1f4845 100644 --- a/src/dgram/dgram_link.c +++ b/src/dgram/dgram_link.c @@ -27,6 +27,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -114,6 +115,10 @@ dgram_do_send(struct onet_link *link, struct dgram_params *params) static int squeak_back(struct onet_link *link, mac_addr_t src, mac_addr_t dst) { + if (link == NULL) { + return -EINVAL; + } + /* * If one were to spoof their address as the broadcast * address, that could end up VERY badly as it would @@ -139,6 +144,10 @@ dgram_send(struct onet_link *link, mac_addr_t dst, void *buf, uint16_t len) { struct dgram_params params; + if (link == NULL || buf == NULL) { + return -EINVAL; + } + params.dst = dst; params.buf = buf; params.len = len; @@ -152,6 +161,10 @@ dgram_squeak(struct onet_link *link, mac_addr_t dst) struct dgram_params params; uint8_t pad[8]; + if (link == NULL) { + return -EINVAL; + } + params.dst = dst; params.buf = pad; params.len = sizeof(pad); -- cgit v1.2.3