cvs: php4 /ext/standard string.c

From: Date: Thu, 03 Jan 2002 20:20:37 +0000
Subject: cvs: php4 /ext/standard string.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-8921@lists.php.net to get a copy of this message
hholzgra Thu Jan 3 15:20:37 2002 EDT Modified files: /php4/ext/standard string.c Log: fix for bug #14832: basename with 2nd parm corrupts source string Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.257 php4/ext/standard/string.c:1.258 --- php4/ext/standard/string.c:1.257 Tue Dec 11 10:30:36 2001 +++ php4/ext/standard/string.c Thu Jan 3 15:20:35 2002 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: string.c,v 1.257 2001/12/11 15:30:36 sebastian Exp $ */ +/* $Id: string.c,v 1.258 2002/01/03 20:20:35 hholzgra Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -1073,14 +1073,16 @@ */ PHPAPI char *php_basename(char *s, size_t len, char *suffix, size_t sufflen) { - char *ret=NULL, *c, *p=NULL, buf='\0'; + char *ret=NULL, *c, *p=NULL, buf='\0', *p2=NULL, buf2='\0'; c = s + len - 1; /* do suffix removal as the unix command does */ if(suffix && (len > sufflen)) { if(!strncmp(suffix, c-sufflen+1, sufflen)) { c -= sufflen; - *(c + 1) = '\0'; + buf2 = *(c + 1); /* Save overwritten char */ + *(c + 1) = '\0'; /* overwrite char */ + p2 = c + 1; /* Save pointer to overwritten char */ } } @@ -1108,6 +1110,7 @@ ret = estrdup(s); } if(buf) *p = buf; + if(buf2) *p2 = buf2; return (ret); } /* }}} */

« previous php.cvs (#8921) next »