From: Wez Furlong Date: Thu, 9 Sep 2004 19:41:07 +0000 (+0000) Subject: avoid ANSI stdio when calling tempnam() to avoid limitations of AT&T libc. X-Git-Tag: PRE_NEW_VM_GEN_PATCH~338 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=751f67d5d1c27fee3d70bbd0228bc1b0ec71d368;p=php avoid ANSI stdio when calling tempnam() to avoid limitations of AT&T libc. --- diff --git a/ext/standard/file.c b/ext/standard/file.c index 785d99432e..f8e08ade00 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -704,7 +704,7 @@ PHP_FUNCTION(tempnam) char *d; char *opened_path; char p[64]; - FILE *fp; + int fd; if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) { WRONG_PARAM_COUNT; @@ -719,8 +719,8 @@ PHP_FUNCTION(tempnam) d = estrndup(Z_STRVAL_PP(arg1), Z_STRLEN_PP(arg1)); strlcpy(p, Z_STRVAL_PP(arg2), sizeof(p)); - if ((fp = php_open_temporary_file(d, p, &opened_path TSRMLS_CC))) { - fclose(fp); + if ((fd = php_open_temporary_fd(d, p, &opened_path TSRMLS_CC)) >= 0) { + close(fd); RETVAL_STRING(opened_path, 0); } else { RETVAL_FALSE;