From nobody Fri Apr 26 06:52:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) client-ip=63.128.21.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1585152004; cv=none; d=zohomail.com; s=zohoarc; b=H6vCbw+SwwJrhbQwcvfTsQ/X2pJYOGB+23nIfAW4DIQeZi8hMk1WP6ZtJF7jcS5ZTwsojwfXxizmHfheLGBErKFGuC5HO1RQy7jciknA1Mu/atogoqPqZerZcNOMnRuMMWMhOpJDAZTQKGEUd1Wh8R01lfq3+WW2l2Zo+q6sM+E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585152004; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=63tNYOhRFha0dbfVkm768dvjiT4L7am6sLF5a9/Xz3c=; b=N2z6u+G3nyODi4HCVkzmOOqamTQzzhw4ZnBp9KXzeTLvb2o+IdO3kuohPABMSKgXnZ8e4fMbdPXYqD2+X1CNXeKic5KP+0oz/7QvC972c+6Q+oWwUSRM/jS+zBF4hB+GKxIXM3BeCFMS+Zbvrila7gvnW0qJ5Zy66XAlMOJF+ns= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) by mx.zohomail.com with SMTPS id 158515200453977.63800425988438; Wed, 25 Mar 2020 09:00:04 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-352-qaXNgzZbPgW1Ks8eUV_AGg-1; Wed, 25 Mar 2020 11:59:58 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 09FD6107ACC4; Wed, 25 Mar 2020 15:59:53 +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 D84DC60BE0; Wed, 25 Mar 2020 15:59:52 +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 996D018089CF; Wed, 25 Mar 2020 15:59:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02PFxi7W013330 for ; Wed, 25 Mar 2020 11:59:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id C8A6594B42; Wed, 25 Mar 2020 15:59:44 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E72D6266E for ; Wed, 25 Mar 2020 15:59:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585152002; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=63tNYOhRFha0dbfVkm768dvjiT4L7am6sLF5a9/Xz3c=; b=YMomyDnLPuDcFg6JtkQjDtA6//M0jCkShxyGjOz0UqDVyi5dOe0bH5HWyEI3bv2Ykv7d/W Cw5QTSY7uwLr7oqmGjMQTjLp0zcZG97Ab2v8PZAaDYPIPAjeI3fPzI0OSz19/mQJ77ss9s HpIInzrYSiiqbDxr1eA49Gl0XYaChTM= X-MC-Unique: qaXNgzZbPgW1Ks8eUV_AGg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/2] qemuxml2xmltest: Wire up 'disk-network-http' case Date: Wed, 25 Mar 2020 16:59:39 +0100 Message-Id: <778a3412f6edfedb542bb291e2859b27ad559931.1585151909.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- .../disk-network-http.x86_64-latest.xml | 71 +++++++++++++++++++ tests/qemuxml2xmltest.c | 2 + 2 files changed, 73 insertions(+) create mode 100644 tests/qemuxml2xmloutdata/disk-network-http.x86_64-lates= t.xml diff --git a/tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml b= /tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml new file mode 100644 index 0000000000..9e78785d0d --- /dev/null +++ b/tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml @@ -0,0 +1,71 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + + + + +
+ + + + + + + + +
+ + + + + + + testcookievalue + blurb + + + +
+ + + + + + + + testcookievalue + blurb + + + +
+ + +
+ + + + + + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index a3c25b4a76..a0d27fdcf8 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1095,6 +1095,8 @@ mymain(void) DO_TEST("disk-backing-chains-index", NONE); DO_TEST("disk-backing-chains-noindex", NONE); + DO_TEST_CAPS_LATEST("disk-network-http"); + DO_TEST("chardev-label", QEMU_CAPS_DEVICE_VIRTIO_RNG); --=20 2.24.1 From nobody Fri Apr 26 06:52:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) client-ip=63.128.21.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1585151999; cv=none; d=zohomail.com; s=zohoarc; b=VRjXwz49Kp77BPMu+8Z7ArBxig1EhkeDkKL5sZ+/oM700X4uhCBVcSJirf6d1kj9O3LeiWmF3AMnUBVdwbAwl/cRGb3PI4Sc8OOgPF7lq6fYCTXlKFP/NmhJJwsbUS+D6e89fiXvioEuwvMTZsy2ZYt9h1VwLb0G87py8AEMheI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585151999; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RsMD4ohTCDtg6kgm4Sdv8e+J21ZPSPHXSJt7HVutM7I=; b=KPQATTXuCut2vAcC4YVD6MmJ8SfWvZ5rWPWE1aFNd0myBsxzIBOT/h4/vVXsP5MW+yrXwke0k1cOdMB37ObvAC/pI/owS/LMVjTWOFuGOZdfEcra+7z7qkLVaVGF+3GZv0w2oHveHPCFpLN6wT8lwogk6uaq1uFvD4sXcLTOUaI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) by mx.zohomail.com with SMTPS id 1585151999011165.49675541059605; Wed, 25 Mar 2020 08:59:59 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-48-OmOy8X1aMnKMo1N6jMtrAg-1; Wed, 25 Mar 2020 11:59:53 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1A93D8018A5; Wed, 25 Mar 2020 15:59:48 +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 CE83D89E76; Wed, 25 Mar 2020 15:59:47 +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 813CF18089C8; Wed, 25 Mar 2020 15:59:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02PFxje2013341 for ; Wed, 25 Mar 2020 11:59:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9DEEF6266E; Wed, 25 Mar 2020 15:59:45 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23D9194B5C for ; Wed, 25 Mar 2020 15:59:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585151997; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=RsMD4ohTCDtg6kgm4Sdv8e+J21ZPSPHXSJt7HVutM7I=; b=KbSEm7tg1wEhQL+eBbIDA9Y9dCSL3uX8dsXclkW4lun2gnB3nf8pWXemAghkOPtGmqaZjV TnI2mz5pcQB5NP4bYxvyXv4h8PlCxPXcKIKQakRCpN8YNBJkRIhXgl/yI0tqmWRlEC4uBD /H9pWT9BxadO0s7Gsx7gE8pm2sv/bEQ= X-MC-Unique: OmOy8X1aMnKMo1N6jMtrAg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/2] virStorageSourceNetCookieValidate: Accept quoted cookie value Date: Wed, 25 Mar 2020 16:59:40 +0100 Message-Id: <35f8fd6380a8a8ac49793613324579f72fea0c75.1585151909.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The quotes are forbidden only inside the value, but the value itself may be enclosed in quotes. Fix the RNG schema and validator and add a test case. https://bugzilla.redhat.com/show_bug.cgi?id=3D1804750 Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- docs/schemas/domaincommon.rng | 2 +- src/util/virstoragefile.c | 19 ++++++++++++++++++- .../disk-network-http.x86_64-latest.args | 4 ++-- tests/qemuxml2argvdata/disk-network-http.xml | 4 ++-- .../disk-network-http.x86_64-latest.xml | 4 ++-- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index d79dee650e..02f1ab1982 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1846,7 +1846,7 @@ - [!#$%&'()*+\-./0-9:>=3D<?@A-= Z\^_`\[\]a-z|~]+ + "?[!#$%&'()*+\-./0-9:>=3D<?@= A-Z\^_`\[\]a-z|~]+"? diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index d81ed70a97..c43e52d1f6 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2217,6 +2217,10 @@ static const char virStorageSourceCookieNameInvalidC= hars[] =3D static int virStorageSourceNetCookieValidate(virStorageNetCookieDefPtr def) { + g_autofree char *val =3D g_strdup(def->value); + const char *checkval =3D val; + size_t len =3D strlen(val); + /* name must have at least 1 character */ if (*(def->name) =3D=3D '\0') { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -2233,8 +2237,21 @@ virStorageSourceNetCookieValidate(virStorageNetCooki= eDefPtr def) return -1; } + /* check for optional quotes around the cookie value string */ + if (val[0] =3D=3D '"') { + if (val[len - 1] !=3D '"') { + virReportError(VIR_ERR_XML_ERROR, + _("value of cookie '%s' contains invalid charac= ters"), + def->name); + return -1; + } + + val[len - 1] =3D '\0'; + checkval++; + } + /* check invalid characters in value */ - if (virStringHasChars(def->value, virStorageSourceCookieValueInvalidCh= ars)) { + if (virStringHasChars(checkval, virStorageSourceCookieValueInvalidChar= s)) { virReportError(VIR_ERR_XML_ERROR, _("value of cookie '%s' contains invalid characters= "), def->name); diff --git a/tests/qemuxml2argvdata/disk-network-http.x86_64-latest.args b/= tests/qemuxml2argvdata/disk-network-http.x86_64-latest.args index e14498f778..ed44424dc3 100644 --- a/tests/qemuxml2argvdata/disk-network-http.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-network-http.x86_64-latest.args @@ -43,7 +43,7 @@ id=3Dvirtio-disk0,bootindex=3D1 \ -device virtio-blk-pci,scsi=3Doff,bus=3Dpci.0,addr=3D0x3,drive=3Dlibvirt-3= -format,\ id=3Dvirtio-disk1 \ -object secret,id=3Dlibvirt-2-storage-httpcookie-secret0,\ -data=3DDrPR9NA6GKJb7qi1KbjHad3f3UIGTTDmAmOZHHv1F5w5T8rhnk3f+uSKStHe0J2O,\ +data=3DDrPR9NA6GKJb7qi1KbjHaealKEMVtOWUl2h3yvO5lgIh6cyLHemmlg+h9fcgwREA,\ keyid=3DmasterKey0,iv=3DAAECAwQFBgcICQoLDA0ODw=3D=3D,format=3Dbase64 \ -blockdev '{"driver":"http","url":"http://example.org:1234/test3.img",\ "cookie-secret":"libvirt-2-storage-httpcookie-secret0",\ @@ -53,7 +53,7 @@ keyid=3DmasterKey0,iv=3DAAECAwQFBgcICQoLDA0ODw=3D=3D,form= at=3Dbase64 \ -device virtio-blk-pci,scsi=3Doff,bus=3Dpci.0,addr=3D0x4,drive=3Dlibvirt-2= -format,\ id=3Dvirtio-disk2 \ -object secret,id=3Dlibvirt-1-storage-httpcookie-secret0,\ -data=3DDrPR9NA6GKJb7qi1KbjHad3f3UIGTTDmAmOZHHv1F5w5T8rhnk3f+uSKStHe0J2O,\ +data=3DDrPR9NA6GKJb7qi1KbjHaealKEMVtOWUl2h3yvO5lgIh6cyLHemmlg+h9fcgwREA,\ keyid=3DmasterKey0,iv=3DAAECAwQFBgcICQoLDA0ODw=3D=3D,format=3Dbase64 \ -blockdev '{"driver":"https","url":"https://example.org:1234/test4.img",\ "sslverify":false,"cookie-secret":"libvirt-1-storage-httpcookie-secret0",\ diff --git a/tests/qemuxml2argvdata/disk-network-http.xml b/tests/qemuxml2a= rgvdata/disk-network-http.xml index 20024c732e..93e6617433 100644 --- a/tests/qemuxml2argvdata/disk-network-http.xml +++ b/tests/qemuxml2argvdata/disk-network-http.xml @@ -35,7 +35,7 @@ testcookievalue - blurb + "blurb" @@ -47,7 +47,7 @@ testcookievalue - blurb + "blurb" diff --git a/tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml b= /tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml index 9e78785d0d..cf36331286 100644 --- a/tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml +++ b/tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml @@ -41,7 +41,7 @@ testcookievalue - blurb + "blurb" @@ -54,7 +54,7 @@ testcookievalue - blurb + "blurb" --=20 2.24.1