Author: ahristov
Date: 2007-09-28 17:25:15 +0200 (Fri, 28 Sep 2007)
New Revision: 1073
Modified:
trunk/php5/ext/mysqli/mysqli.c
trunk/php6/ext/mysqli/mysqli.c
Log:
Fix some local_infile problems, more exists however :(
Modified: trunk/php5/ext/mysqli/mysqli.c
===================================================================
--- trunk/php5/ext/mysqli/mysqli.c 2007-09-28 13:13:12 UTC (rev 1072)
+++ trunk/php5/ext/mysqli/mysqli.c 2007-09-28 15:25:15 UTC (rev 1073)
@@ -1200,7 +1200,7 @@
#define LOCAL_INFILE_ERROR_MSG(source,dest)\
memset(source, 0, LOCAL_INFILE_ERROR_LEN);\
-memcpy(source, dest, LOCAL_INFILE_ERROR_LEN-1);
+memcpy(source, dest, MIN(strlen(dest), LOCAL_INFILE_ERROR_LEN-1));
/* {{{ void php_set_local_infile_handler_default
*/
@@ -1332,6 +1332,16 @@
LOCAL_INFILE_ERROR_MSG(data->error_msg, "Can't execute load data local init callback
function");
rc = -1;
}
+ /*
+ If the (ab)user has closed the file handle we should
+ not try to use it anymore or even close it
+ */
+ if (!zend_rsrc_list_get_rsrc_type(Z_LVAL_P(fp) TSRMLS_CC)) {
+ LOCAL_INFILE_ERROR_MSG(data->error_msg, "File handle closed");
+ rc = -1;
+ /* Thus the end handler won't try to free already freed memory */
+ mysql->li_stream = NULL;
+ }
FREE_CALLBACK_ARGS(callback_args, 1, argc);
efree(fp);
Modified: trunk/php6/ext/mysqli/mysqli.c
===================================================================
--- trunk/php6/ext/mysqli/mysqli.c 2007-09-28 13:13:12 UTC (rev 1072)
+++ trunk/php6/ext/mysqli/mysqli.c 2007-09-28 15:25:15 UTC (rev 1073)
@@ -866,7 +866,9 @@
*/
PHP_MINFO_FUNCTION(mysqli)
{
+#if defined(HAVE_MYSQLND)
char buf[32];
+#endif
php_info_print_table_start();
php_info_print_table_header(2, "MysqlI Support", "enabled");
@@ -1232,7 +1234,7 @@
#define LOCAL_INFILE_ERROR_MSG(source,dest)\
memset(source, 0, LOCAL_INFILE_ERROR_LEN);\
-memcpy(source, dest, LOCAL_INFILE_ERROR_LEN-1);\
+memcpy(source, dest, MIN(strlen(dest), LOCAL_INFILE_ERROR_LEN-1));\
php_error_docref(NULL TSRMLS_CC, E_WARNING, dest);
/* {{{ void php_set_local_infile_handler_default
@@ -1365,6 +1367,16 @@
LOCAL_INFILE_ERROR_MSG(data->error_msg, "Can't execute load data local init callback
function");
rc = -1;
}
+ /*
+ If the (ab)user has closed the file handle we should
+ not try to use it anymore or even close it
+ */
+ if (!zend_rsrc_list_get_rsrc_type(Z_LVAL_P(fp) TSRMLS_CC)) {
+ LOCAL_INFILE_ERROR_MSG(data->error_msg, "File handle closed");
+ rc = -1;
+ /* Thus the end handler won't try to free already freed memory */
+ mysql->li_stream = NULL;
+ }
FREE_CALLBACK_ARGS(callback_args, 1, argc);
efree(fp);
@@ -1404,8 +1416,9 @@
}
return;
}
-
- php_stream_close(mysql->li_stream);
+ if (mysql->li_stream) {
+ php_stream_close(mysql->li_stream);
+ }
free(data);
return;
}
| Thread |
|---|
| • PHP mysqlnd svn commit: r1073 - in trunk: php5/ext/mysqli php6/ext/mysqli | ahristov | 28 Sep |