From b156eaf92f938d4c3c7c4da74dec35d9930f905f Mon Sep 17 00:00:00 2001 From: lizy <821610729@qq.com> Date: Wed, 28 Aug 2024 09:09:23 +0800 Subject: [PATCH] Fix off by one bug when more data is read than buflen #88 --- src/sigar_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sigar_util.c b/src/sigar_util.c index 3c668fc63..325b65ada 100644 --- a/src/sigar_util.c +++ b/src/sigar_util.c @@ -838,7 +838,7 @@ int sigar_file2str(const char *fname, char *buffer, int buflen) return ENOENT; } - if ((len = read(fd, buffer, buflen)) < 0) { + if ((len = read(fd, buffer, buflen - 1)) < 0) { status = errno; } else {