summaryrefslogtreecommitdiff
path: root/src/ipcpd/udp/main.c
diff options
context:
space:
mode:
authorDimitri Staessens <[email protected]>2022-03-07 18:15:58 +0100
committerSander Vrijders <[email protected]>2022-03-08 17:40:18 +0100
commita7032da6bbe875596ea1cb348a747123cda7d408 (patch)
treee6b00543a4199294c06d6bfb42bd1afb293b729d /src/ipcpd/udp/main.c
parent2db119dd5c3e9a1ffc1360bde181a030c08bfce2 (diff)
downloadouroboros-a7032da6bbe875596ea1cb348a747123cda7d408.tar.gz
ouroboros-a7032da6bbe875596ea1cb348a747123cda7d408.zip
ipcpd: Fix memcpy with NULL in piggyback API
If there is no piggyback data, memcpy was passed a NULL pointer in memcpy(buf, NULL, 0) calls, which is undefined behaviour. Signed-off-by: Dimitri Staessens <[email protected]> Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/ipcpd/udp/main.c')
-rw-r--r--src/ipcpd/udp/main.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/ipcpd/udp/main.c b/src/ipcpd/udp/main.c
index 3b354ceb..7def856b 100644
--- a/src/ipcpd/udp/main.c
+++ b/src/ipcpd/udp/main.c
@@ -222,7 +222,8 @@ static int ipcp_udp_port_alloc(const struct sockaddr_in * r_saddr,
msg->timeout = hton32(qs.timeout);
memcpy(msg + 1, dst, ipcp_dir_hash_len());
- memcpy(buf + len, data, dlen);
+ if (dlen > 0)
+ memcpy(buf + len, data, dlen);
if (sendto(udp_data.s_fd, msg, len + dlen,
SENDTO_FLAGS,
@@ -255,7 +256,8 @@ static int ipcp_udp_port_alloc_resp(const struct sockaddr_in * r_saddr,
msg->d_eid = hton32(d_eid);
msg->response = response;
- memcpy(msg + 1, data, len);
+ if (len > 0)
+ memcpy(msg + 1, data, len);
if (sendto(udp_data.s_fd, msg, sizeof(*msg) + len,
SENDTO_FLAGS,