This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=9dff672909dd6e294c5ac199c3c48bf44c823e3a commit 9dff672909dd6e294c5ac199c3c48bf44c823e3a (HEAD -> main) Author: Guillem Jover <guil...@debian.org> AuthorDate: Sat May 4 02:27:44 2024 +0200 libdpkg: Mark file_slurp_fd() NUL-terminate the varbuf While this is not a concern with the current users of these functions, it's still better to NUL-terminate the resulting varbuf, in case a caller will try to use it as a C string directly. --- lib/dpkg/file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/dpkg/file.c b/lib/dpkg/file.c index 7005223dc..2d94bc08e 100644 --- a/lib/dpkg/file.c +++ b/lib/dpkg/file.c @@ -131,10 +131,10 @@ file_slurp_fd(int fd, const char *filename, struct varbuf *vb, if (st.st_size == 0) return 0; - varbuf_init(vb, st.st_size); + varbuf_init(vb, st.st_size + 1); if (fd_read(fd, vb->buf, st.st_size) < 0) return dpkg_put_errno(err, _("cannot read %s"), filename); - vb->used = st.st_size; + varbuf_trunc(vb, st.st_size); return 0; } -- Dpkg.Org's dpkg