diff options
author | Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> | 2015-11-11 17:08:01 +1100 |
---|---|---|
committer | Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> | 2015-12-18 11:15:58 +1100 |
commit | 999fd1a2053421b55cdd876049c40beb2921807f (patch) | |
tree | af1990067820e88b08d66996622185931ae6b945 /discover/user-event.c | |
parent | 45e64e9fbeae206997d347b479e697da2ee53ac5 (diff) | |
download | talos-petitboot-999fd1a2053421b55cdd876049c40beb2921807f.tar.gz talos-petitboot-999fd1a2053421b55cdd876049c40beb2921807f.zip |
discover: Null-terminate buffer in user_event_process()
Fixes Coverity defect #30480
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Diffstat (limited to 'discover/user-event.c')
-rw-r--r-- | discover/user-event.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/discover/user-event.c b/discover/user-event.c index 69defa3..8cad1a9 100644 --- a/discover/user-event.c +++ b/discover/user-event.c @@ -488,10 +488,10 @@ static void user_event_handle_message(struct user_event *uev, char *buf, static int user_event_process(void *arg) { struct user_event *uev = arg; - char buf[PBOOT_USER_EVENT_SIZE]; + char buf[PBOOT_USER_EVENT_SIZE + 1]; int len; - len = recvfrom(uev->socket, buf, sizeof(buf), 0, NULL, NULL); + len = recvfrom(uev->socket, buf, PBOOT_USER_EVENT_SIZE, 0, NULL, NULL); if (len < 0) { pb_log("%s: socket read failed: %s", __func__, strerror(errno)); @@ -503,6 +503,8 @@ static int user_event_process(void *arg) return 0; } + buf[len] = '\0'; + pb_debug("%s: %u bytes\n", __func__, len); user_event_handle_message(uev, buf, len); |