summaryrefslogtreecommitdiff
path: root/src/irmd/main.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2022-03-07 18:15:58 +0100
committerSander Vrijders <sander@ouroboros.rocks>2022-03-08 17:40:18 +0100
commita7032da6bbe875596ea1cb348a747123cda7d408 (patch)
treee6b00543a4199294c06d6bfb42bd1afb293b729d /src/irmd/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 <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/irmd/main.c')
-rw-r--r--src/irmd/main.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/irmd/main.c b/src/irmd/main.c
index fdbc25a7..fab9497d 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -1698,8 +1698,8 @@ static int flow_req_arr(pid_t pid,
}
f->len = len;
-
- memcpy(f->data, data, len);
+ if (len > 0)
+ memcpy(f->data, data, len);
}
list_add(&f->next, &irmd.irm_flows);
@@ -1764,7 +1764,9 @@ static int flow_alloc_reply(int flow_id,
return -1;
}
- memcpy(f->data, data, len);
+ if (len > 0)
+ memcpy(f->data, data, len);
+
f->len = len;
pthread_rwlock_unlock(&irmd.flows_lock);