On Thu, May 14, 2026 at 10:15:24 +0200, Ján Tomko via Devel wrote:
> From: Ján Tomko <jtomko@redhat.com>
>
> On systems with many users, this file can be larger than BUFSIZ.
> Since the file should only be editable by root and virFileReadAll
> reallocates the buffer in increments as needed as opposed to
> allocating for 'maxlen' upfront, set the maximum to INT_MAX.
>
> https://gitlab.com/libvirt/libvirt/-/work_items/874
>
> Signed-off-by: Ján Tomko <jtomko@redhat.com>
> ---
> src/util/virutil.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/util/virutil.c b/src/util/virutil.c
> index 187b8202dd..3e107cdae6 100644
> --- a/src/util/virutil.c
> +++ b/src/util/virutil.c
> @@ -1223,7 +1223,9 @@ virGetSubIDs(virSubID **retval, const char *file)
>
> *retval = NULL;
>
> - if (virFileReadAll(file, BUFSIZ, &buf) < 0)
> + /* We trust the source of the file so we set the limit absurdly high.
> + * For smaller files, the helper function will not allocate as much space */
> + if (virFileReadAll(file, INT_MAX, &buf) < 0)
> return -1;
>
> lines = g_strsplit(buf, "\n", 0);
Reviewed-by: Peter Krempa <pkrempa@redhat.com>