Re: cvs: php4 /main safe_mode.c
| From: | Ilia A. | Date: | Fri, 16 Aug 2002 12:44:10 +0000 |
| Subject: | Re: cvs: php4 /main safe_mode.c | ||
| References: | 1 2 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-13407@lists.php.net to get a copy of this message | ||
On August 16, 2002 07:57 am, you wrote:
> On 08/16/02, "Ilia A." <ilia@prohost.org> wrote:
> > I've tried the patch and it appears to work fine and does what it should.
>
> Good!
>
> > Here is an example:
> > php -r ' var_dump(fopen("ftp://localhost",
> > "r")); '
> > Command line code(1) : Warning - fopen(ftp://localhost)
> > [http://www.php.net/function.fopen]: failed to create stream: FTP server
> > reports 500 localhost FTP server shut down -- please try again later.
> >
> > bool(false)
> > /home/rei/PHP_CVS/php4/main/streams.c(1386) : Freeing 0x0823572C (82
> > bytes), script=-
>
> Is that really latest CVS? line 1386 is a strlen() call.
> Also, does this leak occur for http?
> (I'm slightly too busy to delve in deeper than that for the moment)
>
> --Wez.
The fix you've commited or the patch that I've sent you via email fixes that
leak. There is another potential leak (not freed msg) inside
_php_stream_opendir.
The patch below fixes that problem.
--- main/streams.c_old Fri Aug 16 08:19:05 2002
+++ main/streams.c Fri Aug 16 08:37:12 2002
@@ -1267,7 +1267,7 @@
if (stream == NULL && (options & REPORT_ERRORS)) {
char *tmp = estrdup(path);
- char *msg;
+ char *msg = NULL;
if (wrapper)
msg = strerror(errno);
@@ -1277,6 +1277,7 @@
php_strip_url_passwd(tmp);
zend_error(E_WARNING, "%s(\"%s\") - %s",
get_active_function_name(TSRMLS_C), tmp, msg);
efree(tmp);
+ if( msg ) efree(msg);
}
return stream;
}
Ilia