From 57dc36fca14b314f11bae82b69225b4d324b6bf9 Mon Sep 17 00:00:00 2001
From: Paul Nasrat <pnasrat@fedoraproject.org>
Date: Mar 31 2006 16:18:33 +0000
Subject: "Fix" memory exhaustion with many duplicate basenames on erase and a few

    backports

---

diff --git a/rpm-4.4.2-netsharedpath.patch b/rpm-4.4.2-netsharedpath.patch
new file mode 100644
index 0000000..fe6938a
--- /dev/null
+++ b/rpm-4.4.2-netsharedpath.patch
@@ -0,0 +1,12 @@
+--- rpm-4.4.2/lib/transaction.c.netsharedpath	2006-02-13 18:15:37.000000000 -0500
++++ rpm-4.4.2/lib/transaction.c	2006-02-13 18:15:38.000000000 -0500
+@@ -820,6 +820,9 @@
+ 		    /*@innercontinue@*/ continue;
+ 		if (strncmp(dn, *nsp, dnlen))
+ 		    /*@innercontinue@*/ continue;
++		/* Insure that only the netsharedpath basename is compared. */
++		if ((s = strchr((*nsp) + dnlen, '/')) != NULL && s[1] != '\0')
++		    /*@innercontinue@*/ continue;
+ 		if (strncmp(bn, (*nsp) + dnlen, bnlen))
+ 		    /*@innercontinue@*/ continue;
+ 		len = dnlen + bnlen;
diff --git a/rpm-4.4.2-userlock.patch b/rpm-4.4.2-userlock.patch
new file mode 100644
index 0000000..b6826f8
--- /dev/null
+++ b/rpm-4.4.2-userlock.patch
@@ -0,0 +1,20 @@
+--- rpm-4.4.2/lib/rpmlock.c.userlock	2006-02-23 15:24:46.000000000 -0500
++++ rpm-4.4.2/lib/rpmlock.c	2006-02-23 15:25:53.000000000 -0500
+@@ -37,7 +37,7 @@
+ 
+ 	/* XXX oneshot to determine path for fcntl lock. */
+ 	if (rpmlock_path == NULL) {
+-	    char * t = rpmExpand(rpmlock_path_default, NULL);
++	    char * t = rpmGenPath(rootdir, rpmlock_path_default, NULL);
+ 	    if (t == NULL || *t == '\0' || *t == '%')
+ 		t = RPMLOCK_PATH;
+ 	    rpmlock_path = xstrdup(t);
+@@ -129,7 +129,7 @@
+ 	const char *rootDir = rpmtsRootDir(ts);
+ 	rpmlock lock;
+ 
+-	if (!rootDir)
++	if (!rootDir || rpmtsChrootDone(ts))
+ 		rootDir = "/";
+ 	lock = rpmlock_new(rootDir);
+ /*@-branchstate@*/
diff --git a/rpm-4.4.2-vercmp.patch b/rpm-4.4.2-vercmp.patch
new file mode 100644
index 0000000..0143eb1
--- /dev/null
+++ b/rpm-4.4.2-vercmp.patch
@@ -0,0 +1,27 @@
+--- rpm-4.4.2/lib/rpmvercmp.c.vercmp	2005-07-03 22:32:22.000000000 -0400
++++ rpm-4.4.2/lib/rpmvercmp.c	2006-02-13 18:20:01.000000000 -0500
+@@ -39,6 +39,9 @@
+ 	while (*one && !xisalnum(*one)) one++;
+ 	while (*two && !xisalnum(*two)) two++;
+ 
++	/* If we ran to the end of either, we are finished with the loop */
++	if (!(*one && *two)) break;
++
+ 	str1 = one;
+ 	str2 = two;
+ 
+@@ -64,9 +67,13 @@
+ 	*str2 = '\0';
+ /*@=boundswrite@*/
+ 
++	/* this cannot happen, as we previously tested to make sure that */
++	/* the first string has a non-null segment */
++	if (one == str1) return -1;	/* arbitrary */
++
+ 	/* take care of the case where the two version segments are */
+ 	/* different types: one numeric, the other alpha (i.e. empty) */
+-	if (one == str1) return -1;	/* arbitrary */
++	/* numeric segments are always newer than alpha segments */
+ 	/* XXX See patch #60884 (and details) from bugzilla #50977. */
+ 	if (two == str2) return (isnum ? 1 : -1);
+ 
diff --git a/rpm.spec b/rpm.spec
index 376754d..de4e7a4 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -20,7 +20,7 @@ Name: rpm
 %define version 4.4.2
 Version: %{version}
 %{expand: %%define rpm_version %{version}}
-Release: 15.2
+Release: 16
 Group: System Environment/Base
 Source: ftp://wraptastic.org/pub/rpm-4.4.x/rpm-%{rpm_version}.tar.gz
 Source1: mono-find-provides
@@ -45,6 +45,9 @@ Patch16: rpm-4.4.2-file-softmagic.patch
 Patch17: rpm-4.4.2-no-large-mmap.patch
 Patch18: rpm-4.4.2-perlmainprov.patch
 Patch19: rpm-4.4.2-rpmsq-deadlock.patch
+Patch20: rpm-4.4.2-netsharedpath.patch
+Patch21: rpm-4.4.2-userlock.patch
+Patch22: rpm-4.4.2-vercmp.patch
 License: GPL
 Conflicts: patch < 2.5
 %ifos linux
@@ -168,7 +171,7 @@ shell-like rules.
 %patch9 -p1  -b .contextverify
 %patch10 -p1  -b .charset
 %patch11 -p1  -b .ghostconflicts
-%patch12 -p1  -b .exclude
+#patch12 -p1  -b .exclude
 %patch13 -p1  -b .excludedsize
 %patch14 -p1  -b .cronpath
 %patch15 -p1  -b .mono
@@ -176,6 +179,9 @@ shell-like rules.
 %patch17 -p1 -b .no_large_mmap
 %patch18 -p1 -b .perlmainprov
 %patch19 -p1 -b .deadlock
+%patch20 -p1 -b .netsharedpath
+%patch21 -p1 -b .userlock
+%patch22 -p1 -b .vercmp
 
 %build
 
@@ -568,6 +574,12 @@ exit 0
 %{__includedir}/popt.h
 
 %changelog
+* Fri Mar 31 2006 Paul Nasrat <pnasrat@redhat.com> - 4.4.2-16
+- Skipdirs on erase again (#187308)
+- Make fcntl lock sensitive to --root (#151255)
+- Fix netshared path comparison (#52725)
+- Fix rpm vercmp (#178798)
+
 * Fri Feb 10 2006 Jesse Keating <jkeating@redhat.com> - 4.4.2-15.2
 - bump again for double-long bug on ppc(64)