From: Corne' Cornelius Date: Tue, 1 Jul 2003 12:37:12 +0000 (+0000) Subject: - Removed unlink() from php_intifx_create_blob() and replaced with a php_copy_file() X-Git-Tag: php-4.3.3RC2~196 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ef2d599f454e6ad94971aa0d6650afb950b8f449;p=php - Removed unlink() from php_intifx_create_blob() and replaced with a php_copy_file() --- diff --git a/ext/informix/ifx.ec b/ext/informix/ifx.ec index 10a9627700..6cc09022d6 100644 --- a/ext/informix/ifx.ec +++ b/ext/informix/ifx.ec @@ -3043,20 +3043,20 @@ static long php_intifx_create_blob(long type, long mode, char* param, long len, if (*param && param != "") { - char *filename; - - if (Ifx_blob->BLOB.blob_data.loc_fname != NULL) { - unlink(Ifx_blob->BLOB.blob_data.loc_fname); - efree(Ifx_blob->BLOB.blob_data.loc_fname); - } - if ((filename = emalloc(len + 1)) == NULL) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't create blob-resource"); - return -1; - } - memcpy(filename, param, len); - filename[len] = 0; - Ifx_blob->BLOB.blob_data.loc_fname = filename; - Ifx_blob->BLOB.blob_data.loc_size = -1; + /* + * copy the filename in param to filename in loc_fname + * otherwise we'll unlink non-temporary files + * + * loc_fname gets filled by php_intifx_init_blob_infile + */ + + if (Ifx_blob->BLOB.blob_data.loc_fname != NULL) { + if (php_copy_file(param, Ifx_blob->BLOB.blob_data.loc_fname TSRMLS_CC) == FAILURE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't create blob-resource file. File copy failed: %s", param); + return -1; + } + Ifx_blob->BLOB.blob_data.loc_size = -1; + } } }