Skip to content

Commit

Permalink
Fix off by one bug when more data is read than buflen hyperic#88
Browse files Browse the repository at this point in the history
  • Loading branch information
lizhanyin committed Aug 28, 2024
1 parent aff170e commit b156eaf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/sigar_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b156eaf

Please sign in to comment.