summaryrefslogtreecommitdiff
path: root/ext/phar/zip.c
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2013-05-15 11:17:18 +0200
committerAnatol Belski <ab@php.net>2013-05-15 11:17:18 +0200
commit077b575d51630641fbd4b664bd18cfc335f76ebe (patch)
tree3b0590d3a847f968b721b36e81618a4cbf6f3ca7 /ext/phar/zip.c
parent1f97fde89e5e54c4f360b07d348d0f14634808b3 (diff)
parentde82e7edf7c91afab236a087ce4900868066b5d7 (diff)
downloadphp-git-077b575d51630641fbd4b664bd18cfc335f76ebe.tar.gz
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4: Fix unitialized vars when sql.safe_mode=1 more check for php_stream_fopen_tmpfile failure
Diffstat (limited to 'ext/phar/zip.c')
-rw-r--r--ext/phar/zip.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/ext/phar/zip.c b/ext/phar/zip.c
index 2d57c08c5a..c8057e3bbe 100644
--- a/ext/phar/zip.c
+++ b/ext/phar/zip.c
@@ -1095,6 +1095,10 @@ static int phar_zip_applysignature(phar_archive_data *phar, struct _phar_zip_pas
off_t tell, st;
newfile = php_stream_fopen_tmpfile();
+ if (newfile == NULL) {
+ spprintf(pass->error, 0, "phar error: unable to create temporary file for the signature file");
+ return FAILURE;
+ }
st = tell = php_stream_tell(pass->filefp);
/* copy the local files, central directory, and the zip comment to generate the hash */
php_stream_seek(pass->filefp, 0, SEEK_SET);
@@ -1196,7 +1200,10 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defau
/* set alias */
if (!phar->is_temporary_alias && phar->alias_len) {
entry.fp = php_stream_fopen_tmpfile();
-
+ if (entry.fp == NULL) {
+ spprintf(error, 0, "phar error: unable to create temporary file");
+ return EOF;
+ }
if (phar->alias_len != (int)php_stream_write(entry.fp, phar->alias, phar->alias_len)) {
if (error) {
spprintf(error, 0, "unable to set alias in zip-based phar \"%s\"", phar->fname);
@@ -1271,6 +1278,10 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defau
len = pos - user_stub + 18;
entry.fp = php_stream_fopen_tmpfile();
+ if (entry.fp == NULL) {
+ spprintf(error, 0, "phar error: unable to create temporary file");
+ return EOF;
+ }
entry.uncompressed_filesize = len + 5;
if ((size_t)len != php_stream_write(entry.fp, user_stub, len)
@@ -1304,7 +1315,10 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defau
} else {
/* Either this is a brand new phar (add the stub), or the default stub is required (overwrite the stub) */
entry.fp = php_stream_fopen_tmpfile();
-
+ if (entry.fp == NULL) {
+ spprintf(error, 0, "phar error: unable to create temporary file");
+ return EOF;
+ }
if (sizeof(newstub)-1 != php_stream_write(entry.fp, newstub, sizeof(newstub)-1)) {
php_stream_close(entry.fp);
if (error) {