From 07f864d06b69bae2eb1173a51b38876adbb514ca Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Sun, 31 Aug 2003 21:07:01 +0000 Subject: [PATCH] Make sure that ftp->data is nulled after it's freed. This may fix bug #25294 & bug #25296. --- ext/ftp/ftp.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c index caeebb421f..cb0c3b47e3 100644 --- a/ext/ftp/ftp.c +++ b/ext/ftp/ftp.c @@ -818,8 +818,7 @@ ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, 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; @@ -827,8 +826,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; } /* }}} */ @@ -903,14 +901,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; } /* }}} */ @@ -1627,7 +1625,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; @@ -1665,7 +1663,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); @@ -1729,7 +1727,7 @@ ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t typ return (ftp_nb_continue_read(ftp TSRMLS_CC)); bail: - data_close(ftp, data); + ftp->data = data_close(ftp, data); return PHP_FTP_FAILED; } /* }}} */ @@ -1782,7 +1780,7 @@ ftp_nb_continue_read(ftpbuf_t *ftp TSRMLS_DC) 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; @@ -1792,7 +1790,7 @@ ftp_nb_continue_read(ftpbuf_t *ftp TSRMLS_DC) return PHP_FTP_FINISHED; bail: ftp->nb = 0; - data_close(ftp, data); + ftp->data = data_close(ftp, data); return PHP_FTP_FAILED; } /* }}} */ @@ -1845,7 +1843,7 @@ ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type return (ftp_nb_continue_write(ftp TSRMLS_CC)); bail: - data_close(ftp, data); + ftp->data = data_close(ftp, data); return PHP_FTP_FAILED; } /* }}} */ @@ -1897,7 +1895,7 @@ ftp_nb_continue_write(ftpbuf_t *ftp TSRMLS_DC) 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; } -- 2.40.0