com php-src: Fix bug #77967 - Bypassing open_basedir restri ctions via file uris: NEWS ext/sqlite3/sqlite3 .c

From: Date: Tue, 28 May 2019 07:03:25 +0000
Subject: com php-src: Fix bug #77967 - Bypassing open_basedir restri ctions via file uris: NEWS ext/sqlite3/sqlite3 .c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-106374@lists.php.net to get a copy of this message
Commit: d27b4824e667c5ed3eac9c16496777392eae5b03 Author: Stanislav Malyshev <stas@php.net> Mon, 27 May 2019 18:04:00 -0700 Committer: Christoph M. Becker <cmbecker69@gmx.de> Tue, 28 May 2019 09:03:25 +0200 Parents: 70523ce41ff400ea00343a03f297332cb1f1b77b Branches: PHP-7.3.6 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d27b4824e667c5ed3eac9c16496777392eae5b03 Log: Fix bug #77967 - Bypassing open_basedir restrictions via file uris (cherry picked from commit c34895e837b50213c2bb201c612904342d2bd216) Bugs: https://bugs.php.net/77967 Changed paths: M NEWS M ext/sqlite3/sqlite3.c Diff: diff --git a/NEWS b/NEWS index db237e6..e111572 100644 --- a/NEWS +++ b/NEWS @@ -47,6 +47,9 @@ PHP NEWS . Fixed bug #77024 (SplFileObject::__toString() may return array). (Craig Duncan) +- SQLite: + . Fixed bug #77967 (Bypassing open_basedir restrictions via file uris). (Stas) + - Standard: . Fixed bug #77931 (Warning for array_map mentions wrong type). (Nikita) . Fixed bug #78003 (strip_tags output change since PHP 7.3). (cmb) diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 43ae172..6ae049a 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -2067,6 +2067,15 @@ static int php_sqlite3_authorizer(void *autharg, int access_type, const char *ar case SQLITE_ATTACH: { if (memcmp(arg3, ":memory:", sizeof(":memory:")) && *arg3) { + if (strncmp(arg3, "file:", 5) == 0) { + /* starts with "file:" */ + if (!arg3[5]) { + return SQLITE_DENY; + } + if (php_check_open_basedir(arg3 + 5)) { + return SQLITE_DENY; + } + } if (php_check_open_basedir(arg3)) { return SQLITE_DENY; }

« previous php.cvs (#106374) next »