From: Ilia Alshanetsky Date: Sun, 31 Aug 2003 21:09:14 +0000 (+0000) Subject: MFH: Make sure that ftp->data is nulled after it's freed. This may fix bug X-Git-Tag: php-4.3.4RC1~134 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6ce26891e87b2fcec4d0704d9bbf0707581337a5;p=php MFH: Make sure that ftp->data is nulled after it's freed. This may fix bug #25294 & bug #25296. --- diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c index c3bf8a4464..1d20ec2fc3 100644 --- a/ext/ftp/ftp.c +++ b/ext/ftp/ftp.c @@ -715,8 +715,7 @@ ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, if (type == FTPTYPE_ASCII && lastch == '\r') php_stream_putc(outstream, '\r'); - data = data_close(ftp, data); - ftp->data = NULL; + ftp->data = data = data_close(ftp, data); if (!ftp_getresp(ftp) || (ftp->resp != 226 && ftp->resp != 250)) { goto bail; @@ -724,8 +723,7 @@ ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, return 1; bail: - data_close(ftp, data); - ftp->data = NULL; + ftp->data = data_close(ftp, data); return 0; } /* }}} */ @@ -798,14 +796,14 @@ ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, i if (size && my_send(ftp, data->fd, data->buf, size) != size) goto bail; - data = data_close(ftp, data); + ftp->data = data = data_close(ftp, data); if (!ftp_getresp(ftp) || (ftp->resp != 226 && ftp->resp != 250)) goto bail; return 1; bail: - data_close(ftp, data); + ftp->data = data_close(ftp, data); return 0; } /* }}} */ @@ -1498,7 +1496,7 @@ ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC) } } - data = data_close(ftp, data); + ftp->data = data = data_close(ftp, data); if (ferror(tmpfp)) goto bail; @@ -1538,7 +1536,7 @@ ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC) return ret; bail: if (data) - data_close(ftp, data); + ftp->data = data_close(ftp, data); fclose(tmpfp); if (ret) efree(ret); @@ -1594,7 +1592,7 @@ ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t typ return (ftp_nb_continue_read(ftp)); bail: - data_close(ftp, data); + ftp->data = data_close(ftp, data); return PHP_FTP_FAILED; } /* }}} */ @@ -1647,7 +1645,7 @@ ftp_nb_continue_read(ftpbuf_t *ftp) if (type == FTPTYPE_ASCII && lastch == '\r') php_stream_putc(ftp->stream, '\r'); - data = data_close(ftp, data); + ftp->data = data = data_close(ftp, data); if (!ftp_getresp(ftp) || (ftp->resp != 226 && ftp->resp != 250)) { goto bail; @@ -1657,7 +1655,7 @@ ftp_nb_continue_read(ftpbuf_t *ftp) return PHP_FTP_FINISHED; bail: ftp->nb = 0; - data_close(ftp, data); + ftp->data = data_close(ftp, data); return PHP_FTP_FAILED; } /* }}} */ @@ -1709,7 +1707,7 @@ ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type return (ftp_nb_continue_write(ftp)); bail: - data_close(ftp, data); + ftp->data = data_close(ftp, data); return PHP_FTP_FAILED; } @@ -1764,7 +1762,7 @@ ftp_nb_continue_write(ftpbuf_t *ftp) ftp->nb = 0; return PHP_FTP_FINISHED; bail: - data_close(ftp, ftp->data); + ftp->data = data_close(ftp, ftp->data); ftp->nb = 0; return PHP_FTP_FAILED; }