From: Daniel Golle Date: Sun, 15 Aug 2021 11:34:05 +0000 (+0100) Subject: service: make sure string read is null terminated X-Git-Url: http://git.openwrt.org/?p=project%2Fprocd.git;a=commitdiff_plain;h=48f481b0bfbfdf54a03b767b9559405ad2404d6e service: make sure string read is null terminated Coverity CID: 1490007 String not null terminated Signed-off-by: Daniel Golle --- diff --git a/service/service.c b/service/service.c index b3286dc..419f96c 100644 --- a/service/service.c +++ b/service/service.c @@ -324,6 +324,9 @@ static void put_cgroups(struct blob_buf *b) return; ret = read(fd, &buf, sizeof(buf)); + /* make sure buffer is NULL-terminated */ + buf[sizeof(buf)-1] = '\0'; + close(fd); if (ret < 2)