You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Dean Gaudet <dg...@arctic.org> on 1997/12/14 02:53:45 UTC

[PATCH] PR#1319: RedirectMatch gone / causes SIGSEGV

RedirectMatch gone / causes a SIGSEGV.  This is fixed here. 

But when I was testing Redirect gone / I found it wasn't working right... 
it turns out to be a bug introduced by a change to alloc.c between
revisions 1.41 and 1.42 -- Stanley Gambarin pointed out that pstrcat(p,
NULL) returned bogosity (an uninitialized byte) and suggested that it
return NULL in this case.  I put that in... but it turns out that
mod_alias was relying on it returning something non-NULL even in this
case.  So this patch includes a tweak which causes pstrcat(p, NULL) to
return an empty string... which should be more compatible.

Dean

Index: main/alloc.c
===================================================================
RCS file: /export/home/cvs/apachen/src/main/alloc.c,v
retrieving revision 1.60
diff -u -r1.60 alloc.c
--- alloc.c	1997/12/07 21:33:18	1.60
+++ alloc.c	1997/12/14 01:50:05
@@ -553,11 +553,9 @@
 
     /* Allocate the required string */
 
-    if (len == 0) {
-	return NULL;
-    }
     res = (char *) palloc(a, len + 1);
     cp = res;
+    *cp = '\0';
 
     /* Pass two --- copy the argument strings into the result space */
 
Index: modules/standard/mod_alias.c
===================================================================
RCS file: /export/home/cvs/apachen/src/modules/standard/mod_alias.c,v
retrieving revision 1.26
diff -u -r1.26 mod_alias.c
--- mod_alias.c	1997/10/22 20:30:13	1.26
+++ mod_alias.c	1997/12/14 01:50:05
@@ -297,10 +297,16 @@
 
 	if (p->regexp) {
 	    if (!regexec(p->regexp, r->uri, p->regexp->re_nsub + 1, regm, 0)) {
-		found = pregsub(r->pool, p->real, r->uri,
-				p->regexp->re_nsub + 1, regm);
-		if (found && doesc) {
-		    found = escape_uri(r->pool, found);
+		if (p->real) {
+		    found = pregsub(r->pool, p->real, r->uri,
+				    p->regexp->re_nsub + 1, regm);
+		    if (found && doesc) {
+			found = escape_uri(r->pool, found);
+		    }
+		}
+		else {
+		    /* need something non-null */
+		    found = pstrdup(r->pool, "");
 		}
 	    }
 	}




Re: [PATCH] PR#1319: RedirectMatch gone / causes SIGSEGV

Posted by Martin Kraemer <Ma...@mch.sni.de>.
On Sat, Dec 13, 1997 at 05:53:45PM -0800, Dean Gaudet wrote:
> So this patch includes a tweak which causes pstrcat(p, NULL) to
> return an empty string... which should be more compatible.

Yes, good idea. +1 (untested).

    Martin
-- 
| S I E M E N S |  <Ma...@mch.sni.de>  |      Siemens Nixdorf
| ------------- |   Voice: +49-89-636-46021     |  Informationssysteme AG
| N I X D O R F |   FAX:   +49-89-636-44994     |   81730 Munich, Germany
~~~~~~~~~~~~~~~~My opinions only, of course; pgp key available on request

Re: [PATCH] PR#1319: RedirectMatch gone / causes SIGSEGV

Posted by Ben Laurie <be...@algroup.co.uk>.
Dean Gaudet wrote:
> 
> RedirectMatch gone / causes a SIGSEGV.  This is fixed here.
> 
> But when I was testing Redirect gone / I found it wasn't working right...
> it turns out to be a bug introduced by a change to alloc.c between
> revisions 1.41 and 1.42 -- Stanley Gambarin pointed out that pstrcat(p,
> NULL) returned bogosity (an uninitialized byte) and suggested that it
> return NULL in this case.  I put that in... but it turns out that
> mod_alias was relying on it returning something non-NULL even in this
> case.  So this patch includes a tweak which causes pstrcat(p, NULL) to
> return an empty string... which should be more compatible.

+1 (untested).

Cheers,

Ben.

-- 
Ben Laurie            |Phone: +44 (181) 735 0686|Apache Group member
Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |Apache-SSL author
A.L. Digital Ltd,     |http://www.algroup.co.uk/Apache-SSL
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache