781232 +tags patch
thanks

Hi,
On Sun, Sep 06, 2015 at 11:34:49AM +0200, Guido Günther wrote:
> Hi Aron,
> On Sat, Sep 05, 2015 at 02:35:49PM +0200, Guido Günther wrote:
> > tags 781232 +patch
> > thanks
> > 
> > Hi Salvatore, Hi Aron,
> > On Mon, Aug 31, 2015 at 11:02:48AM +0200, Salvatore Bonaccorso wrote:
> > > Hi Aron,
> > > 
> > > Specific for the issue now seen for #781232: Looked shortly at
> > > https://bugzilla.gnome.org/show_bug.cgi?id=731063#c1 According to that
> > > comment the original patch lead to more issues (e.g.  the one which we
> > > see now) and more patches were applied. I have though not tried to
> > > skim trough to check which are required.
> > 
> > Attached patch resolves the libvirt related regression for me. It's a
> > straight cherry pick from upstream commit
> > 
> >     beb7281055dbf0ed4d041022a67c6c5cfd126f25
> > 
> > Can we have this in sid please? It would also be great to have this
> > backported to Jessie since libvirt is there affected as well. (And yes,
> > I do think the severity is correct).
> 
> I've uploaded a NMU to delayed 7days so in case nobody has time to take
> care of it it will get fixed eventually. We can always dcut it.
> 
> Let me know if I should take care of stable as well?

Attached is the diff from the NUM announced above.
Cheers,
 -- Guido
diff --git a/debian/changelog b/debian/changelog
index f7ec7e5..b670771 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+libxml2 (2.9.2+really2.9.1+dfsg1-0.2) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix a problem unparsing URIs without a host part like qemu:///system.
+    This unbreaks libvirt, libsys-virt-perl and others
+    (Closes: #781232)
+
+ -- Guido Günther <a...@sigxcpu.org>  Sun, 06 Sep 2015 11:16:48 +0200
+
 libxml2 (2.9.2+really2.9.1+dfsg1-0.1) unstable; urgency=medium
 
   * Non-maintainer upload.
diff --git a/debian/patches/Fix-a-problem-properly-saving-URIs.patch b/debian/patches/Fix-a-problem-properly-saving-URIs.patch
new file mode 100644
index 0000000..71c4261
--- /dev/null
+++ b/debian/patches/Fix-a-problem-properly-saving-URIs.patch
@@ -0,0 +1,125 @@
+From: Daniel Veillard <veill...@redhat.com>
+Date: Fri, 3 Oct 2014 19:22:39 +0800
+Subject: Fix a problem properly saving URIs
+
+As written by Martin Kletzander <mklet...@redhat.com>:
+Since commit 8eb55d782a2b9afacc7938694891cc6fad7b42a5, when you parse
+and save an URI that has no server (or similar) part, two slashes
+after the 'schema:' get lost.  It means 'uri:///noserver' is turned
+into 'uri:/noserver'.
+
+basically
+   foo:///only/path
+
+means a host of "" while
+
+   foo:/only/path
+
+means no host at all
+
+  So the best fix IMHO is to fix the URI parser to record the first
+case and an empty host string and the second case as a NULL host string
+
+ I would not revert the initial patch, we should not 'invent' those
+slash, but we should instead when parsing keep the information that
+it's a host based path and that foo:/// means the presence of a host
+but an empty one.
+
+Once applied the resulting patch below, all cases seems to be saved
+properly:
+
+thinkpad:~/XML -> ./testURI uri:/noserver
+uri:/noserver
+thinkpad:~/XML -> ./testURI uri:///noserver
+uri:///noserver
+thinkpad:~/XML -> ./testURI uri://server/foo
+uri://server/foo
+thinkpad:~/XML -> ./testURI uri:/noserver/foo
+uri:/noserver/foo
+thinkpad:~/XML -> ./testURI uri:///
+uri:///
+thinkpad:~/XML -> ./testURI uri://
+uri://
+thinkpad:~/XML -> ./testURI uri:/
+uri:/
+thinkpad:~/XML ->
+
+  If you revert the initial patch that last case fails
+
+The problem is that I don't want to change the xmlURI structure to
+minimize ABI breakage, so I could not extend the field. The natural
+solution is to denote that uri:/// has an empty host by making
+the uri server field an empty string which works very well but breaks
+applications (like libvirt ;-) who blindly look at uri->server
+not being NULL to try to reach it !
+Simplest was to stick the port to -1 in that case, instead of 0
+application don't bother looking at the port of there is no server
+string, this makes the patch more complex than a 1 liner, but
+is better for ABI.
+
+Closes: #781232
+---
+ uri.c | 34 +++++++++++++++++++---------------
+ 1 file changed, 19 insertions(+), 15 deletions(-)
+
+diff --git a/uri.c b/uri.c
+index d4dcd2f..ff47abb 100644
+--- a/uri.c
++++ b/uri.c
+@@ -759,6 +759,8 @@ xmlParse3986HierPart(xmlURIPtr uri, const char **str)
+         cur += 2;
+ 	ret = xmlParse3986Authority(uri, &cur);
+ 	if (ret != 0) return(ret);
++	if (uri->server == NULL)
++	    uri->port = -1;
+ 	ret = xmlParse3986PathAbEmpty(uri, &cur);
+ 	if (ret != 0) return(ret);
+ 	*str = cur;
+@@ -1106,7 +1108,7 @@ xmlSaveUri(xmlURIPtr uri) {
+ 	    }
+ 	}
+     } else {
+-	if (uri->server != NULL) {
++	if ((uri->server != NULL) || (uri->port == -1)) {
+ 	    if (len + 3 >= max) {
+                 temp = xmlSaveUriRealloc(ret, &max);
+                 if (temp == NULL) goto mem_error;
+@@ -1143,22 +1145,24 @@ xmlSaveUri(xmlURIPtr uri) {
+ 		}
+ 		ret[len++] = '@';
+ 	    }
+-	    p = uri->server;
+-	    while (*p != 0) {
+-		if (len >= max) {
+-                    temp = xmlSaveUriRealloc(ret, &max);
+-                    if (temp == NULL) goto mem_error;
+-                    ret = temp;
++	    if (uri->server != NULL) {
++		p = uri->server;
++		while (*p != 0) {
++		    if (len >= max) {
++			temp = xmlSaveUriRealloc(ret, &max);
++			if (temp == NULL) goto mem_error;
++			ret = temp;
++		    }
++		    ret[len++] = *p++;
+ 		}
+-		ret[len++] = *p++;
+-	    }
+-	    if (uri->port > 0) {
+-		if (len + 10 >= max) {
+-                    temp = xmlSaveUriRealloc(ret, &max);
+-                    if (temp == NULL) goto mem_error;
+-                    ret = temp;
++		if (uri->port > 0) {
++		    if (len + 10 >= max) {
++			temp = xmlSaveUriRealloc(ret, &max);
++			if (temp == NULL) goto mem_error;
++			ret = temp;
++		    }
++		    len += snprintf((char *) &ret[len], max - len, ":%d", uri->port);
+ 		}
+-		len += snprintf((char *) &ret[len], max - len, ":%d", uri->port);
+ 	    }
+ 	} else if (uri->authority != NULL) {
+ 	    if (len + 3 >= max) {
diff --git a/debian/patches/series b/debian/patches/series
index 5d07130..8c70a58 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -57,3 +57,4 @@
 0057-Cleanup-conditional-section-error-handling.patch
 0058-Fix-upstream-bug-299127.patch
 0059-CVE-2015-1819-Enforce-the-reader-to-run-in-constant-.patch
+Fix-a-problem-properly-saving-URIs.patch

Reply via email to