Re: [xslt] Release of libxslt-1.0.31



Attached please find two patches:
	patch-01-nanoxxx-ipv6-logic for libxml2-2.5.8
and
	patch-01-typecast for libxslt-1.0.31

When looking through the gcc warnings (on linux-gnu, with -O2) I found a few
suspicious ones, that where either due to doubious program logic, or could
be easily avoided with a typecast.

regards
Peter Breitenlohner <peb@mppmu.mpg.de>
	This is patch-01-nanoxx-ipv6-logic

	This patch tries to avoid the gcc warning (with -O2)
		nanoftp.c: In function `xmlNanoFTPConnect':
		nanoftp.c:1001: warning: `addrlen' might be used uninitialized in this function
	and
		nanohttp.c: In function `xmlNanoHTTPConnectHost':
		nanohttp.c:956: warning: `addr' might be used uninitialized in this function
	A closer inspection reveales, that the existing code in both routines
	is most probably broken, possibly leading to
		(1) the use of an uninitialized socket
		(2) a memory leak

NOTE 1:
	Wouldn't it be a good idea to use the same progam logic (and
	as far as possible the identical code) in both nanoftp and nanoftp.
	At the moment nanohttp tries all possible IP addresses, whereas
	nanoftp tries just the first one found and gives up if this fails.

NOTE 2:
	If it were guaranteed that all implementations of freeaddrinfo can
	handle a NULL argument, then
	    if (result)
		freeaddrinfo (result);
	below could be replaced by
	    freeaddrinfo (result);
	(twice) but who knows.

diff -ur libxml2-2.5.8.orig/nanoftp.c libxml2-2.5.8/nanoftp.c
--- libxml2-2.5.8.orig/nanoftp.c	2003-06-21 16:09:33.000000000 +0200
+++ libxml2-2.5.8/nanoftp.c	2003-07-09 23:31:57.000000000 +0200
@@ -1038,7 +1038,12 @@
 	    if (res->ai_family == AF_INET || res->ai_family == AF_INET6)
 		break;
 
-	if (res) {
+	if (!res) {
+	    if (result)
+		freeaddrinfo (result);
+	    return (-1);
+	}
+	else {
 	    if (res->ai_family == AF_INET6) {
 		memcpy (&ctxt->ftpAddr, res->ai_addr, res->ai_addrlen);
 		((struct sockaddr_in6 *) &ctxt->ftpAddr)->sin6_port = htons (port);
diff -ur libxml2-2.5.8.orig/nanohttp.c libxml2-2.5.8/nanohttp.c
--- libxml2-2.5.8.orig/nanohttp.c	2003-07-06 22:53:44.000000000 +0200
+++ libxml2-2.5.8/nanohttp.c	2003-07-09 23:44:10.000000000 +0200
@@ -993,14 +993,13 @@
 	}
 
 	for (res = result; res; res = res->ai_next) {
-	    if (res) {
+	    if (res->ai_family == AF_INET || res->ai_family == AF_INET6) {
 		if (res->ai_family == AF_INET6) {
 		    memcpy (&sockin6, res->ai_addr, res->ai_addrlen);
 		    sockin6.sin6_port = htons (port);
 		    addr = (struct sockaddr *)&sockin6;
 		}
-
-		if (res->ai_family == AF_INET) {
+		else {
 		    memcpy (&sockin, res->ai_addr, res->ai_addrlen);
 		    sockin.sin_port = htons (port);
 		    addr = (struct sockaddr *)&sockin;
@@ -1012,11 +1011,10 @@
 		    return (s);
 		}
 	    }
-	    else {
-		freeaddrinfo (result);
-		return (-1);
-	    }
 	}
+	if (result)
+	    freeaddrinfo (result);
+	return (-1);
     } else
 #endif
 #endif
	This is patch-01-typecast

	This patch tries to avoid the gcc warning
		transform.c: In function `xsltCopy':
		transform.c:2331: warning: passing arg 3 of `xsltCopyNamespace' \
			from incompatible pointer type

	Assuming that xmlNsPtr is a specialization (subclass) of xmlNodePtr,
	and that node->type==XML_NAMESPACE_DECL indicates that the
	xmlNodePtr node is indeed such an xmlNsPtr, all one needs is a
	typecast.

diff -ur libxslt-1.0.31.orig/libxslt/transform.c libxslt-1.0.31/libxslt/transform.c
--- libxslt-1.0.31.orig/libxslt/transform.c	2003-07-06 18:26:16.000000000 +0200
+++ libxslt-1.0.31/libxslt/transform.c	2003-07-09 21:26:02.000000000 +0200
@@ -2328,7 +2328,7 @@
 		xsltGenericDebug(xsltGenericDebugContext,
 				 "xsltCopy: namespace declaration\n");
 #endif
-                xsltCopyNamespace(ctxt, ctxt->insert, node);
+                xsltCopyNamespace(ctxt, ctxt->insert, (xmlNsPtr) node);
 		break;
 	    default:
 		break;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]