Skip to content

Commit af51675

Browse files
committed
Merge branch 'PHP-5.3' into PHP-5.4
* PHP-5.3: Improve check for :memory: pseudo-filename in SQlite Conflicts: ext/sqlite3/sqlite3.c
2 parents 041dd77 + 055ecbc commit af51675

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

‎ext/pdo_sqlite/sqlite_driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ static struct pdo_dbh_methods sqlite_methods = {
760760

761761
static char *make_filename_safe(const char *filename TSRMLS_DC)
762762
{
763-
if (*filename && strncmp(filename, ":memory:", sizeof(":memory:")-1)) {
763+
if (*filename && memcmp(filename, ":memory:", sizeof(":memory:"))) {
764764
char *fullpath = expand_filepath(filename, NULL TSRMLS_CC);
765765

766766
if (!fullpath) {

‎ext/sqlite3/sqlite3.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ PHP_METHOD(sqlite3, open)
114114
zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Already initialised DB Object", 0 TSRMLS_CC);
115115
}
116116

117-
if (strncmp(filename, ":memory:", 8) != 0) {
117+
if (strlen(filename) != filename_len) {
118+
return;
119+
}
120+
if (memcmp(filename, ":memory:", sizeof(":memory:")) != 0) {
118121
if (!(fullpath = expand_filepath(filename, NULL TSRMLS_CC))) {
119122
zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Unable to expand filepath", 0 TSRMLS_CC);
120123
return;
@@ -1959,7 +1962,7 @@ static int php_sqlite3_authorizer(void *autharg, int access_type, const char *ar
19591962
switch (access_type) {
19601963
case SQLITE_ATTACH:
19611964
{
1962-
if (strncmp(arg3, ":memory:", sizeof(":memory:")-1) && *arg3) {
1965+
if (memcmp(arg3, ":memory:", sizeof(":memory:")) && *arg3) {
19631966
TSRMLS_FETCH();
19641967

19651968
#if PHP_API_VERSION < 20100412

0 commit comments

Comments
 (0)