From: Marcus Boerger Date: Mon, 5 Feb 2007 22:11:27 +0000 (+0000) Subject: - Check temp file creation X-Git-Tag: RELEASE_1_0_0RC1~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=45d63c39736c7b5dbae1d2980a25d26bf470d78a;p=php - Check temp file creation --- diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 7434fb4bb8..c85e2c0068 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -381,6 +381,12 @@ static int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len if (for_write) { /* open a new temp file for writing */ entry->fp = php_stream_fopen_tmpfile(); + if (!entry->fp) { + if (error) { + spprintf(error, 0, "phar error: unable to create temprary file"); + } + return FAILURE; + } (*ret)->fp = entry->fp; entry->is_modified = 1; phar->is_modified = 1; @@ -468,6 +474,12 @@ phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char memset(&etemp, 0, sizeof(phar_entry_info)); etemp.filename_len = path_len; etemp.fp = php_stream_fopen_tmpfile(); + if (!etemp.fp) { + if (error) { + spprintf(error, 0, "phar error: unable to create temorary file"); + } + return NULL; + } etemp.fp_refcount = 1; etemp.is_modified = 1; etemp.filename = estrndup(path, path_len); @@ -1904,6 +1916,15 @@ int phar_flush(phar_archive_data *archive, char *user_stub, long len, char **err closeoldfile = oldfile != NULL; } newfile = php_stream_fopen_tmpfile(); + if (!newfile) { + if (error) { + spprintf(error, 0, "unable to create temporary file"); + } + if (closeoldfile) { + php_stream_close(oldfile); + } + return EOF; + } if (user_stub) { if (len < 0) { @@ -2068,6 +2089,17 @@ int phar_flush(phar_archive_data *archive, char *user_stub, long len, char **err in read count */ entry->compressed_filesize = 0; entry->cfp = php_stream_fopen_tmpfile(); + if (!entry->cfp) { + if (error) { + spprintf(error, 0, "unable to create temporary file"); + } + if (closeoldfile) { + php_stream_close(oldfile); + } + php_stream_close(newfile); + efree(buf); + return EOF; + } do { read = php_stream_read(file, buf, 8192); if (read) {