and prevent such errors in php_do_open_temporary_file()
char buf[4096];
char *path;
- tmp = php_open_temporary_file("", "", &path TSRMLS_CC);
+ tmp = php_open_temporary_file(NULL, NULL, &path TSRMLS_CC);
if (tmp == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open temporary file");
RETURN_FALSE;
{
char *trailing_slash;
char *opened_path;
+ int path_len = 0;
int fd = -1;
#ifndef HAVE_MKSTEMP
int open_flags = O_CREAT | O_TRUNC | O_RDWR
return -1;
}
+ path_len = strlen(path);
+
if (!(opened_path = emalloc(MAXPATHLEN))) {
return -1;
}
- if (IS_SLASH(path[strlen(path)-1])) {
+ if (!path_len || IS_SLASH(path[path_len - 1])) {
trailing_slash = "";
} else {
trailing_slash = "/";