From nobody Tue Jun 9 21:00:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1778746699; cv=none; d=zohomail.com; s=zohoarc; b=h5J/4OjDnboTXOq57meP42giG4k+XSEkInXOwM05i9sbXL1K7kJqw3jOL/eAR1dRggn7ndK0+lF/32M5UadRHFbeURjnOFQAewExhYEemNIqDVhXejzlYkp3PKayAxXW6UE/eBAX9hWQwF/2NqSQ0l8fOMsQTZGYHOyl31fm5SE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778746699; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Subject:Subject:To:To:Message-Id:Cc; bh=DbWByMV5A0a4gDfkpk9NTTr2AqsJlWdcz0shvfDqano=; b=gfl9rMe+SKle5y3tDt/0kHMJvWGd8FCei8E+EtWzTvcM2Vc6/sUCnuVQKFC9Ai6HWLP5XtUt0FODDPtC7VhsQ23/eKpGHX5XYzSHRe3EZ6pFTVR3BNtvh/+wk4TfU21QjjdGDRTvOUtEKlUucKiAORARqqpj2YqTABPtGQ+sdTo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1778746699894689.8059357391946; Thu, 14 May 2026 01:18:19 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 0E04541867; Thu, 14 May 2026 04:18:17 -0400 (EDT) Received: from [172.19.199.9] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 07F2941851; Thu, 14 May 2026 04:16:03 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 1A2873F34D; Thu, 14 May 2026 04:15:54 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id DC94D3F282 for ; Thu, 14 May 2026 04:15:49 -0400 (EDT) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-650-LZSmDFCGMjmXgxSKeq0HRA-1; Thu, 14 May 2026 04:15:47 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AF4451800343 for ; Thu, 14 May 2026 08:15:46 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.33.180]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E03DA1956053 for ; Thu, 14 May 2026 08:15:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778746549; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DbWByMV5A0a4gDfkpk9NTTr2AqsJlWdcz0shvfDqano=; b=jQHx86/p5eNWPd+f7Ggri3p0y+LHwqkptihjcg4woPri/xU3cjC/hGf4Zwj0GQImWMf7Hy oq1UpFyLEuQ+5id3RMZuggyIIAQn8EYRDp3KM7EjFQA74F7YlXFFo9CWlnLBhNOADbjuiM ZPYjBaWq8MYwy5E0cG0DFWfJ2VzW6/k= X-MC-Unique: LZSmDFCGMjmXgxSKeq0HRA-1 X-Mimecast-MFC-AGG-ID: LZSmDFCGMjmXgxSKeq0HRA_1778746546 To: devel@lists.libvirt.org Subject: [libvirt PATCH] util: virGetSubIDs: do not limit file size Date: Thu, 14 May 2026 10:15:24 +0200 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: xNnJz3f_loIwn3DEFqoZXcFOYrY49KYTeS3clyNoJOU_1778746546 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: W54BRVVR4ONEIBHEOYT6IKGWTG276KZJ X-Message-ID-Hash: W54BRVVR4ONEIBHEOYT6IKGWTG276KZJ X-MailFrom: jtomko@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: =?utf-8?q?J=C3=A1n_Tomko_via_Devel?= Reply-To: =?UTF-8?q?J=C3=A1n=20Tomko?= X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1778746702023158500 From: J=C3=A1n Tomko 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=C3=A1n Tomko Reviewed-by: Peter Krempa --- 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) =20 *retval =3D NULL; =20 - 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 sp= ace */ + if (virFileReadAll(file, INT_MAX, &buf) < 0) return -1; =20 lines =3D g_strsplit(buf, "\n", 0); --=20 2.54.0