Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hubzhangxj opened this issue Nov 23, 2021 · 1 comment

Comments

@hubzhangxj
Copy link

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;

}

@hubzhangxj
Copy link
Author

linux fd(PROC_STAT)equal to 8192,
Linux platform
stdio.h:# define BUFSIZ _IO_BUFSIZ
libio.h:#define _IO_BUFSIZ _G_BUFSIZ
_G_config.h:#define _G_BUFSIZ 8192

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant