Skip to content

master/src/sigar_util.c/sigar_file2str would be running out of memory when len equal to 8192 #149

Description

@hubzhangxj

int sigar_file2str(const char *fname, char *buffer, int buflen)
{
int len, status;
int fd = open(fname, O_RDONLY);

if (fd < 0) {
    return ENOENT;
}

if ((len = read(fd, buffer, buflen)) < 0) {
    status = errno;
}
else {
    status = SIGAR_OK;
   /* buffer[len] = '\0'; is bug? */
    buffer[len - 1] = '\0';
}
close(fd);

return status;

}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions