diff options
author | krakjoe <joe.watkins@live.co.uk> | 2014-02-02 14:42:54 +0000 |
---|---|---|
committer | krakjoe <joe.watkins@live.co.uk> | 2014-02-02 14:42:54 +0000 |
commit | ee42849f8f70b412c58eae83be08c523a2448d47 (patch) | |
tree | 645bd6234796b9c0628c0cfc7ac2043df6f4347b | |
parent | 37f4f132fc5889ceef0df40d9f43acb4bcfb0387 (diff) | |
parent | 9e84124e2dba2fc652abce076d5d1bbac9ed13bd (diff) | |
download | php-git-ee42849f8f70b412c58eae83be08c523a2448d47.tar.gz |
Merge branch 'PHP-5.6'
* PHP-5.6:
better use of tmpnam/mkstemp
-rw-r--r-- | sapi/phpdbg/phpdbg.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 7c94ac19dd..9341ad35a5 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -831,7 +831,13 @@ int main(int argc, char **argv) /* {{{ */ zend_bool remote = 0; int run = 0; int step = 0; - char *bp_tmp_file; + +#ifdef _WIN32 + char *bp_tmp_file = NULL; +#else + char bp_tmp_file[] = "/tmp/phpdbg.XXXXXX"; +#endif + #ifndef _WIN32 char *address; int listen[2]; @@ -871,10 +877,23 @@ int main(int argc, char **argv) /* {{{ */ phpdbg_main: if (!cleaning) { + +#ifdef _WIN32 bp_tmp_file = malloc(L_tmpnam); - tmpnam(bp_tmp_file); - if (bp_tmp_file == NULL) { + if (bp_tmp_file) { + if (!tmpnam(bp_tmp_file)) { + free(bp_tmp_file); + bp_tmp_file = NULL; + } + } +#else + if (!mkstemp(bp_tmp_file)) { + memset(bp_tmp_file, 0, sizeof(bp_tmp_file)); + } +#endif + + if (!bp_tmp_file) { phpdbg_error("Unable to create temporary file"); } } @@ -1317,7 +1336,11 @@ phpdbg_out: free(sapi_name); } +#ifdef _WIN32 free(bp_tmp_file); +#else + unlink(bp_tmp_file); +#endif return 0; } /* }}} */ |