diff options
author | Carlo Teubner <carlo@cteubner.net> | 2021-10-03 09:24:06 +0200 |
---|---|---|
committer | Andrew Gregory <andrew.gregory.8@gmail.com> | 2021-11-20 12:36:59 -0800 |
commit | 806ccd90ede19a69a013206641e5c6e330950d07 (patch) | |
tree | ec3450e4cc25fa2e534c85d21d7a538ff02e29ca /src | |
parent | b242f5f24c938a02c44e644619607af679668337 (diff) |
"pacman -Q --changelog": fix writing uninit'd mem
Previously, when printing a package changelog to stdout, we would write
chunks of data that were not necessarily nul-terminated to stdout using
a function (fputs) which requires the input string to be nul-terminated.
On my system, this would result in occasional garbage characters showing
up in the "pacman -Qc" output.
Fix this by never nul-terminating the chunk, and using the fwrite()
function which takes an explicit input size and does not require a
nul-terminated string.
Signed-off-by: Carlo Teubner <carlo@cteubner.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/pacman/package.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/src/pacman/package.c b/src/pacman/package.c index eaee3bb0..3eae9797 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -466,11 +466,7 @@ void dump_pkg_changelog(alpm_pkg_t *pkg) char buf[CLBUF_SIZE]; size_t ret = 0; while((ret = alpm_pkg_changelog_read(buf, CLBUF_SIZE, pkg, fp))) { - if(ret < CLBUF_SIZE) { - /* if we hit the end of the file, we need to add a null terminator */ - *(buf + ret) = '\0'; - } - fputs(buf, stdout); + fwrite(buf, 1, ret, stdout); } alpm_pkg_changelog_close(pkg, fp); putchar('\n'); |