diff options
author | Dimitri Staessens <[email protected]> | 2022-03-07 18:15:58 +0100 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2022-03-08 17:40:18 +0100 |
commit | a7032da6bbe875596ea1cb348a747123cda7d408 (patch) | |
tree | e6b00543a4199294c06d6bfb42bd1afb293b729d /src/ipcpd/unicast/fa.c | |
parent | 2db119dd5c3e9a1ffc1360bde181a030c08bfce2 (diff) | |
download | ouroboros-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/unicast/fa.c')
-rw-r--r-- | src/ipcpd/unicast/fa.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/ipcpd/unicast/fa.c b/src/ipcpd/unicast/fa.c index eb467a90..508f2d73 100644 --- a/src/ipcpd/unicast/fa.c +++ b/src/ipcpd/unicast/fa.c @@ -847,7 +847,8 @@ int fa_alloc(int fd, msg->timeout = hton32(qs.timeout); memcpy(msg + 1, dst, ipcp_dir_hash_len()); - memcpy(shm_du_buff_head(sdb) + len, data, dlen); + if (dlen > 0) + memcpy(shm_du_buff_head(sdb) + len, data, dlen); if (dt_write_packet(addr, qc, fa.eid, sdb)) { ipcp_sdb_release(sdb); @@ -897,7 +898,8 @@ int fa_alloc_resp(int fd, msg->s_eid = hton64(flow->s_eid); msg->response = response; - memcpy(msg + 1, data, len); + if (len > 0) + memcpy(msg + 1, data, len); if (response < 0) { fa_flow_fini(flow); |