com php-src: better use of tmpnam/mkstemp: phpdbg.c

From: Date: Sun, 02 Feb 2014 14:42:31 +0000
Subject: com php-src: better use of tmpnam/mkstemp: phpdbg.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-82816@lists.php.net to get a copy of this message
Commit: 1deeec0ba870b94d10f4a909193b4c47bc7a028d Author: krakjoe <joe.watkins@live.co.uk> Sun, 2 Feb 2014 14:42:31 +0000 Parents: 591e64ff5898dfcb6dcd49729546f823a6b0e775 Branches: PHP-5.6 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1deeec0ba870b94d10f4a909193b4c47bc7a028d Log: better use of tmpnam/mkstemp Changed paths: M phpdbg.c Diff: diff --git a/phpdbg.c b/phpdbg.c index 7c94ac1..9341ad3 100644 --- a/phpdbg.c +++ b/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; } /* }}} */

« previous php.cvs (#82816) next »