From nobody Fri Mar 29 08:59:52 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.zoho.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 149064632729847.02358794146198; Mon, 27 Mar 2017 13:25:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DD4FE1C13C0; Mon, 27 Mar 2017 20:25:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AA323179C3; Mon, 27 Mar 2017 20:25:25 +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 648995EC63; Mon, 27 Mar 2017 20:25:25 +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 v2RKKvt2018187 for ; Mon, 27 Mar 2017 16:20:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2C75417A79; Mon, 27 Mar 2017 20:20:57 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 25B7660F83 for ; Mon, 27 Mar 2017 20:20:55 +0000 (UTC) Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.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 297EDC054907 for ; Mon, 27 Mar 2017 20:20:54 +0000 (UTC) Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v2RKKrtX013554 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 27 Mar 2017 20:20:53 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.13.8/8.14.4) with ESMTP id v2RKKqGi028633 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Mon, 27 Mar 2017 20:20:52 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v2RKKqU8010911; Mon, 27 Mar 2017 20:20:52 GMT Received: from nina.dynamic.ziggo.nl (/10.175.210.25) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 27 Mar 2017 13:20:52 -0700 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DD4FE1C13C0 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=oracle.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DD4FE1C13C0 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 297EDC054907 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=oracle.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=wim.ten.have@oracle.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 297EDC054907 From: Wim Ten Have To: Libvirt Development List Date: Mon, 27 Mar 2017 22:20:43 +0200 Message-Id: <20170327202043.18950-2-wim.ten.have@oracle.com> In-Reply-To: <20170327202043.18950-1-wim.ten.have@oracle.com> References: <20170327202043.18950-1-wim.ten.have@oracle.com> X-Source-IP: aserv0021.oracle.com [141.146.126.233] X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 203 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 27 Mar 2017 20:20:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 27 Mar 2017 20:20:54 +0000 (UTC) for IP:'156.151.31.81' DOMAIN:'userp1040.oracle.com' HELO:'userp1040.oracle.com' FROM:'wim.ten.have@oracle.com' RCPT:'' X-RedHat-Spam-Score: -104.401 (BAYES_50, DCC_REPUT_13_19, RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY, USER_IN_WHITELIST) 156.151.31.81 userp1040.oracle.com 156.151.31.81 userp1040.oracle.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Wim ten Have Subject: [libvirt] [PATCH] virConfSaveValue: protect against a NULL pointer reference 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 27 Mar 2017 20:25:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Wim ten Have Fix xlconfigtest runs build for --enable-test-oom on Xen XL-2-XML Parse channel-pty Program received signal SIGSEGV, Segmentation fault. #0 0x00007ffff3c2b373 in __strchr_sse2 () from /lib64/libc.so.6 =3D=3D> #1 0x00007ffff7875701 in virConfSaveValue (buf=3Dbuf@entry=3D0x7ff= fffffd8a0, val=3Dval@entry=3D0x674750) at util/virconf.c:290 #2 0x00007ffff7875668 in virConfSaveValue (buf=3Dbuf@entry=3D0x7ffffff= fd8a0, val=3D) at util/virconf.c:306 #3 0x00007ffff78757ef in virConfSaveEntry (buf=3Dbuf@entry=3D0x7ffffff= fd8a0, cur=3Dcur@entry=3D0x674780) at util/virconf.c:338 #4 0x00007ffff78783eb in virConfWriteMem (memory=3D0x665570 "", len=3D= len@entry=3D0x7fffffffd910, conf=3Dconf@entry=3D0x65b940) at util/virconf.c:1543 #5 0x000000000040eccb in testCompareParseXML (replaceVars=3D, xml=3D, xlcfg=3D0x662c00 "/home/wtenhave/WORK/libvirt/OOMtesting/libvirt-de= vel/tests/xlconfigdata/test-channel-pty.cfg") at xlconfigtest.c:108 #6 testCompareHelper (data=3D) at xlconfigtest.c:205 #7 0x0000000000410b3a in virTestRun (title=3Dtitle@entry=3D0x432cc0 "X= en XL-2-XML Parse channel-pty", body=3Dbody@entry=3D0x40e9b0 , data=3Ddata@entry= =3D0x7fffffffd9f0) at testutils.c:247 #8 0x000000000040f322 in mymain () at xlconfigtest.c:278 #9 0x0000000000411410 in virTestMain (argc=3D1, argv=3D0x7fffffffdba8,= func=3D0x40f660 ) at testutils.c:992 #10 0x00007ffff3bc0401 in __libc_start_main () from /lib64/libc.so.6 #11 0x000000000040e86a in _start () (gdb) frame 1 #1 0x00007ffff7875701 in virConfSaveValue (buf=3Dbuf@entry=3D0x7ffffff= fd8a0, val=3Dval@entry=3D0x674750) at util/virconf.c:290 290 if (strchr(val->str, '\n') !=3D NULL) { (gdb) print *val $1 =3D {type =3D VIR_CONF_STRING, next =3D 0x0, l =3D 0, str =3D 0x0, l= ist =3D 0x0} Signed-off-by: Wim ten Have --- src/util/virconf.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/util/virconf.c b/src/util/virconf.c index a85a307..9840ca6 100644 --- a/src/util/virconf.c +++ b/src/util/virconf.c @@ -287,14 +287,16 @@ virConfSaveValue(virBufferPtr buf, virConfValuePtr va= l) virBufferAsprintf(buf, "%llu", val->l); break; case VIR_CONF_STRING: - if (strchr(val->str, '\n') !=3D NULL) { - virBufferAsprintf(buf, "\"\"\"%s\"\"\"", val->str); - } else if (strchr(val->str, '"') =3D=3D NULL) { - virBufferAsprintf(buf, "\"%s\"", val->str); - } else if (strchr(val->str, '\'') =3D=3D NULL) { - virBufferAsprintf(buf, "'%s'", val->str); - } else { - virBufferAsprintf(buf, "\"\"\"%s\"\"\"", val->str); + if (val->str) { + if (strchr(val->str, '\n') !=3D NULL) { + virBufferAsprintf(buf, "\"\"\"%s\"\"\"", val->str); + } else if (strchr(val->str, '"') =3D=3D NULL) { + virBufferAsprintf(buf, "\"%s\"", val->str); + } else if (strchr(val->str, '\'') =3D=3D NULL) { + virBufferAsprintf(buf, "'%s'", val->str); + } else { + virBufferAsprintf(buf, "\"\"\"%s\"\"\"", val->str); + } } break; case VIR_CONF_LIST: { --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list