From e0b4f3ff37dfbea6ffb559f46575de7cc86d26be Mon Sep 17 00:00:00 2001 From: 3D-I Date: Tue, 23 Mar 2021 02:01:45 +0100 Subject: [PATCH 1/4] [ticket/16735] Fix access array offset on value of type bool on login PHPBB3-16735 --- phpBB/phpbb/auth/provider/db.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/auth/provider/db.php b/phpBB/phpbb/auth/provider/db.php index a50e1343f6..adb6554e72 100644 --- a/phpBB/phpbb/auth/provider/db.php +++ b/phpBB/phpbb/auth/provider/db.php @@ -153,8 +153,10 @@ class db extends base } $login_error_attempts = 'LOGIN_ERROR_ATTEMPTS'; - $show_captcha = ($this->config['max_login_attempts'] && $row['user_login_attempts'] >= $this->config['max_login_attempts']) || - ($this->config['ip_login_limit_max'] && $attempts >= $this->config['ip_login_limit_max']); + + $show_captcha = ($row) ? ($this->config['max_login_attempts'] && $row['user_login_attempts'] >= $this->config['max_login_attempts']) || + ($this->config['ip_login_limit_max'] && $attempts >= $this->config['ip_login_limit_max']) : false; + if ($show_captcha) { $captcha = $this->captcha_factory->get_instance($this->config['captcha_plugin']); From 5b84c51d8165f3b93499504e0471ce9524a82d22 Mon Sep 17 00:00:00 2001 From: 3D-I Date: Tue, 23 Mar 2021 02:41:04 +0100 Subject: [PATCH 2/4] [ticket/16735] Fix access array offset on value of type bool on login PHPBB3-16735 --- phpBB/phpbb/auth/provider/db.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/auth/provider/db.php b/phpBB/phpbb/auth/provider/db.php index adb6554e72..2b8cc0d93b 100644 --- a/phpBB/phpbb/auth/provider/db.php +++ b/phpBB/phpbb/auth/provider/db.php @@ -154,8 +154,10 @@ class db extends base $login_error_attempts = 'LOGIN_ERROR_ATTEMPTS'; - $show_captcha = ($row) ? ($this->config['max_login_attempts'] && $row['user_login_attempts'] >= $this->config['max_login_attempts']) || - ($this->config['ip_login_limit_max'] && $attempts >= $this->config['ip_login_limit_max']) : false; + $user_login_attempts = $row ? ($this->config['max_login_attempts'] && $row['user_login_attempts'] >= $this->config['max_login_attempts']) : false; + $ip_login_attempts = (bool) ($this->config['ip_login_limit_max'] && $attempts >= $this->config['ip_login_limit_max']); + + $show_captcha = $user_login_attempts || $ip_login_attempts; if ($show_captcha) { From 736b619294e92ec79048a66334307c637ecb557a Mon Sep 17 00:00:00 2001 From: 3D-I Date: Tue, 23 Mar 2021 22:17:37 +0100 Subject: [PATCH 3/4] [ticket/16735] Fix access array offset on value of type bool on login Remove redundant type casting PHPBB3-16735 --- phpBB/phpbb/auth/provider/db.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/auth/provider/db.php b/phpBB/phpbb/auth/provider/db.php index 2b8cc0d93b..b20cdcf781 100644 --- a/phpBB/phpbb/auth/provider/db.php +++ b/phpBB/phpbb/auth/provider/db.php @@ -155,7 +155,7 @@ class db extends base $login_error_attempts = 'LOGIN_ERROR_ATTEMPTS'; $user_login_attempts = $row ? ($this->config['max_login_attempts'] && $row['user_login_attempts'] >= $this->config['max_login_attempts']) : false; - $ip_login_attempts = (bool) ($this->config['ip_login_limit_max'] && $attempts >= $this->config['ip_login_limit_max']); + $ip_login_attempts = ($this->config['ip_login_limit_max'] && $attempts >= $this->config['ip_login_limit_max']); $show_captcha = $user_login_attempts || $ip_login_attempts; From c4efe5d0fa733afe6da127067e9a13ec041fc762 Mon Sep 17 00:00:00 2001 From: 3D-I Date: Tue, 23 Mar 2021 23:57:43 +0100 Subject: [PATCH 4/4] [ticket/16735] Fix access array offset on value of type bool on login properly check if is an array first PHPBB3-16735 --- phpBB/phpbb/auth/provider/db.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/auth/provider/db.php b/phpBB/phpbb/auth/provider/db.php index b20cdcf781..4810a9587e 100644 --- a/phpBB/phpbb/auth/provider/db.php +++ b/phpBB/phpbb/auth/provider/db.php @@ -154,7 +154,7 @@ class db extends base $login_error_attempts = 'LOGIN_ERROR_ATTEMPTS'; - $user_login_attempts = $row ? ($this->config['max_login_attempts'] && $row['user_login_attempts'] >= $this->config['max_login_attempts']) : false; + $user_login_attempts = (is_array($row) && $this->config['max_login_attempts'] && $row['user_login_attempts'] >= $this->config['max_login_attempts']); $ip_login_attempts = ($this->config['ip_login_limit_max'] && $attempts >= $this->config['ip_login_limit_max']); $show_captcha = $user_login_attempts || $ip_login_attempts;