Skip to content

Commit d1d0d0b

Browse files
committed
Bug #22059. ftp_chdir() causes segfault. efree(ftp->pwd) was being called without knowing for certain that ftp->pwd
actually pointed anywhere.
1 parent aa8dfa0 commit d1d0d0b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ PHP 4 NEWS
33
? ? ??? 200?, Version 5.0.0
44
- Moved extensions to PECL (http://pear.php.net/): (James, Tal)
55
. ext/fribidi
6+
- Fixed bug #22059 (ftp_chdir causes segfault). (Sara)
67
- Fixed bug #20442 (upgraded bundled expat to 1.95.5). (Ilia)
78
- Fixed bug #20155 (xmlrpc compile problem with ZE2). (Derick, Jan Schneider)
89
- Changed get_extension_funcs() to return list of the built-in Zend Engine

ext/ftp/ftp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,8 @@ ftp_chdir(ftpbuf_t *ftp, const char *dir)
473473
return 0;
474474
}
475475

476-
efree(ftp->pwd);
476+
if (ftp->pwd)
477+
efree(ftp->pwd);
477478

478479
if (!ftp_putcmd(ftp, "CWD", dir)) {
479480
return 0;
@@ -494,7 +495,8 @@ ftp_cdup(ftpbuf_t *ftp)
494495
return 0;
495496
}
496497

497-
efree(ftp->pwd);
498+
if (ftp->pwd)
499+
efree(ftp->pwd);
498500

499501
if (!ftp_putcmd(ftp, "CDUP", NULL)) {
500502
return 0;

0 commit comments

Comments
 (0)