From nobody Mon Apr 29 10:28:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 151009434994640.269023194725946; Tue, 7 Nov 2017 14:39:09 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7590F267FD; Tue, 7 Nov 2017 22:39:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4766236F9; Tue, 7 Nov 2017 22:39:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 10DD51800BDC; Tue, 7 Nov 2017 22:39:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vA7McMlG026691 for ; Tue, 7 Nov 2017 17:38:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id 270FB60C8D; Tue, 7 Nov 2017 22:38:22 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4495F60C94; Tue, 7 Nov 2017 22:38:20 +0000 (UTC) Received: from smtp2.provo.novell.com (smtp2.provo.novell.com [137.65.250.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 95DD4A58A5; Tue, 7 Nov 2017 22:38:18 +0000 (UTC) Received: from linux-tbji.provo.novell.com (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (NOT encrypted); Tue, 07 Nov 2017 15:38:09 -0700 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7590F267FD Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7590F267FD DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 95DD4A58A5 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jfehlig@suse.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 95DD4A58A5 From: Jim Fehlig To: libvir-list@redhat.com Date: Tue, 7 Nov 2017 15:37:46 -0700 Message-Id: <20171107223746.4263-1-jfehlig@suse.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 205 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 07 Nov 2017 22:38:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 07 Nov 2017 22:38:19 +0000 (UTC) for IP:'137.65.250.81' DOMAIN:'smtp2.provo.novell.com' HELO:'smtp2.provo.novell.com' FROM:'jfehlig@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.81 smtp2.provo.novell.com 137.65.250.81 smtp2.provo.novell.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: wei.liu2@citrix.com, wim.ten.have@oracle.com Subject: [libvirt] [PATCH] virconf: properly set the end of content X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 07 Nov 2017 22:39:08 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There was a recent report of the xen-xl converter not handling config files missing an ending newline https://www.redhat.com/archives/libvir-list/2017-October/msg01353.html Commit 3cc2a9e0 fixed a similar problem when parsing content of a file but missed parsing in-memory content. But AFAICT, the better fix is to properly set the end of the content when initializing the virConfParserCtxt in virConfParse(). This commit reverts the part of 3cc2a9e0 that appends a newline to files missing it, and fixes setting the end of content when initializing virConfParserCtxt. Signed-off-by: Jim Fehlig --- src/util/virconf.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/util/virconf.c b/src/util/virconf.c index 39c2bd917..a82a509ca 100644 --- a/src/util/virconf.c +++ b/src/util/virconf.c @@ -705,7 +705,7 @@ virConfParse(const char *filename, const char *content,= int len, =20 ctxt.filename =3D filename; ctxt.base =3D ctxt.cur =3D content; - ctxt.end =3D content + len - 1; + ctxt.end =3D content + len; ctxt.line =3D 1; =20 ctxt.conf =3D virConfCreate(filename, flags); @@ -745,7 +745,7 @@ virConfReadFile(const char *filename, unsigned int flag= s) { char *content; int len; - virConfPtr conf =3D NULL; + virConfPtr conf; =20 VIR_DEBUG("filename=3D%s", NULLSTR(filename)); =20 @@ -757,17 +757,8 @@ virConfReadFile(const char *filename, unsigned int fla= gs) if ((len =3D virFileReadAll(filename, MAX_CONFIG_FILE_SIZE, &content))= < 0) return NULL; =20 - if (len && len < MAX_CONFIG_FILE_SIZE && content[len - 1] !=3D '\n') { - VIR_DEBUG("appending newline to busted config file %s", filename); - if (VIR_REALLOC_N(content, len + 2) < 0) - goto cleanup; - content[len++] =3D '\n'; - content[len] =3D '\0'; - } - conf =3D virConfParse(filename, content, len, flags); =20 - cleanup: VIR_FREE(content); =20 return conf; --=20 2.14.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list