From ae7c73ec7fae50aacf6bfe7b9659ad0f3e5f9de6 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Sun, 26 Jan 2014 13:29:43 +0000 Subject: [PATCH] Make sure cmdline string always is null terminated, even if it is very long (Coverity CID 1164484). --- src/bootlogd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bootlogd.c b/src/bootlogd.c index 9343997..f6c8716 100644 --- a/src/bootlogd.c +++ b/src/bootlogd.c @@ -303,9 +303,10 @@ int consolename(char *res, size_t rlen) perror("bootlogd: /proc/cmdline"); } else { buf[0] = 0; - if ((n = read(fd, buf, sizeof(buf) - 1)) >= 0) + if ((n = read(fd, buf, sizeof(buf) - 1)) >= 0) { r = 0; - else + buf[sizeof(buf)-1] = 0; /* enforce null termination */ + } else perror("bootlogd: /proc/cmdline"); close(fd); }