diff options
author | Ian Moffett <ian@osmora.org> | 2025-09-25 22:59:23 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-09-25 22:59:23 -0400 |
commit | c237e0b558fa6ae2a1417f4b4df14212b8721ba8 (patch) | |
tree | b63513edd9ba581b79187541a0123aef74d743c6 /src | |
parent | 9895b548037cb63de561594d517520c738b31943 (diff) |
link: Add NULL checks
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/dgram/dgram_link.c | 13 |
1 files changed, 13 insertions, 0 deletions
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 <sys/errno.h> #include <sys/socket.h> #include <netinet/in.h> #include <linux/if_packet.h> @@ -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); |