Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/pdo_sqlite/sqlite_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ static char *make_filename_safe(const char *filename)
}
return estrdup(filename);
}
if (*filename && memcmp(filename, ":memory:", sizeof(":memory:"))) {
if (*filename && zend_binary_strcmp(filename, strlen(filename), ":memory:", strlen(":memory:"))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I prefer just a regular call to strcmp, simpler and prevents computing the length too.
The binary strcmp doesn't rlly have an advantage when using strlen.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it :)

char *fullpath = expand_filepath(filename, NULL);

if (!fullpath) {
Expand Down
18 changes: 18 additions & 0 deletions ext/pdo_sqlite/tests/gh13991.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
Fix GH-13984: Buffer size is now checked before memcmp
--EXTENSIONS--
pdo_sqlite
--SKIPIF--
<?php if (file_exists(getcwd() . '/13991db')) die('skip File "13991db" already exists.'); ?>
--FILE--
<?php
$dbfile = '13991db';
$db = new PDO('sqlite:' . $dbfile, null, null, [PDO::ATTR_PERSISTENT => true]);
echo 'done!';
?>
--CLEAN--
<?php
@unlink(getcwd() . '/13991db');
?>
--EXPECT--
done!