diff options
| author | Hauke Mehrtens | 2018-12-19 09:51:57 +0000 |
|---|---|---|
| committer | Hauke Mehrtens | 2018-12-27 12:22:26 +0000 |
| commit | e2b055edf26419c183f4bdc3aa47da789081f72e (patch) | |
| tree | 90c548b7a100cc705c4da09a20bd86dc4eae7a86 | |
| parent | d6673547adc3768ce674799fa35952351866c9d0 (diff) | |
| download | procd-e2b055edf26419c183f4bdc3aa47da789081f72e.tar.gz | |
hotplug.c: Make sure hotplug buffer is NULL terminated
Sets the final byte explicitly to NULL because we later do string
operations on this buffer.
Fixes Coverity issue 1430926 String not null terminated
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
| -rw-r--r-- | plug/hotplug.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/plug/hotplug.c b/plug/hotplug.c index 80e6e4d..799123d 100644 --- a/plug/hotplug.c +++ b/plug/hotplug.c @@ -545,11 +545,13 @@ static void hotplug_handler(struct uloop_fd *u, unsigned int ev) { int i = 0; static char buf[4096]; - int len = recv(u->fd, buf, sizeof(buf), MSG_DONTWAIT); + int len = recv(u->fd, buf, sizeof(buf) - 1, MSG_DONTWAIT); void *index; if (len < 1) return; + buf[len] = '\0'; + blob_buf_init(&b, 0); index = blobmsg_open_table(&b, NULL); while (i < len) { |