Skip to content

Commit 055ecbc

Browse files
committed
Improve check for :memory: pseudo-filename in SQlite
1 parent d93892d commit 055ecbc

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ PHP_METHOD(sqlite3, open)
117117
if (strlen(filename) != filename_len) {
118118
return;
119119
}
120-
if (strncmp(filename, ":memory:", 8) != 0) {
120+
if (memcmp(filename, ":memory:", sizeof(":memory:")) != 0) {
121121
if (!(fullpath = expand_filepath(filename, NULL TSRMLS_CC))) {
122122
zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Unable to expand filepath", 0 TSRMLS_CC);
123123
return;
@@ -1962,7 +1962,7 @@ static int php_sqlite3_authorizer(void *autharg, int access_type, const char *ar
19621962
switch (access_type) {
19631963
case SQLITE_ATTACH:
19641964
{
1965-
if (strncmp(arg3, ":memory:", sizeof(":memory:")-1) && *arg3) {
1965+
if (memcmp(arg3, ":memory:", sizeof(":memory:")) && *arg3) {
19661966
TSRMLS_FETCH();
19671967

19681968
#if PHP_API_VERSION < 20100412

0 commit comments

Comments
 (0)