aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
diff options
context:
space:
mode:
authorVishal Pandey <vishpandey2014@gmail.com>2017-03-14 00:57:28 +0530
committerMarc Alexander <admin@m-a-styles.de>2019-05-08 21:48:52 +0200
commit26acd8a5e43f6fc697728f04f4966b26bbd05230 (patch)
tree3ed10501036c2b527a1222a3ac72b4f7cf872682 /phpBB/phpbb
parent4282cf459ec1246ca5a92d4b82ae673695ff382e (diff)
downloadforums-26acd8a5e43f6fc697728f04f4966b26bbd05230.tar
forums-26acd8a5e43f6fc697728f04f4966b26bbd05230.tar.gz
forums-26acd8a5e43f6fc697728f04f4966b26bbd05230.tar.bz2
forums-26acd8a5e43f6fc697728f04f4966b26bbd05230.tar.xz
forums-26acd8a5e43f6fc697728f04f4966b26bbd05230.zip
[ticket/11515] Extra check after acquiring locks.
Add additional check to flock.php and db.php to ensure lock aquiring. PHPBB3-11515
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r--phpBB/phpbb/config/config.php21
-rw-r--r--phpBB/phpbb/lock/db.php11
-rw-r--r--phpBB/phpbb/lock/flock.php7
3 files changed, 37 insertions, 2 deletions
diff --git a/phpBB/phpbb/config/config.php b/phpBB/phpbb/config/config.php
index aaad333006..036ae32cef 100644
--- a/phpBB/phpbb/config/config.php
+++ b/phpBB/phpbb/config/config.php
@@ -148,6 +148,27 @@ class config implements \ArrayAccess, \IteratorAggregate, \Countable
}
/**
+ * Checks configuration option's value only if the new_value matches the
+ * current configuration value and the configuration value does exist.Called
+ *only after set_atomic has been called.
+ *
+ * @param string $key The configuration option's name
+ * @param string $old_value Current configuration value
+ * @param string $new_value New configuration value
+ * @throws \phpbb\exception\http_exception when configuration value is set and not equal to *new_value.
+ * @return bool True if the value was changed, false otherwise.
+ */
+ public function ensure_lock($key, $new_value)
+ {
+ if(isset($this->config[$key]) && $this->config[$key] == $new_value)
+ {
+ return true;
+ } else {
+ throw new \phpbb\exception\http_exception(500, 'Failure while aqcuiring locks.');
+ }
+ }
+
+ /**
* Increments an integer configuration value.
*
* @param string $key The configuration option's name
diff --git a/phpBB/phpbb/lock/db.php b/phpBB/phpbb/lock/db.php
index 85ba9a7aa3..7765619422 100644
--- a/phpBB/phpbb/lock/db.php
+++ b/phpBB/phpbb/lock/db.php
@@ -110,7 +110,16 @@ class db
// process we failed to acquire the lock.
$this->locked = $this->config->set_atomic($this->config_name, $lock_value, $this->unique_id, false);
- return $this->locked;
+ if ($this->locked == true)
+ {
+ if ($this->config->ensure_lock($this->config_name, $this->unique_id))
+ {
+ return true;
+ }
+ } else {
+
+ return $this->locked;
+ }
}
/**
diff --git a/phpBB/phpbb/lock/flock.php b/phpBB/phpbb/lock/flock.php
index df88e1490a..89ff7cbe48 100644
--- a/phpBB/phpbb/lock/flock.php
+++ b/phpBB/phpbb/lock/flock.php
@@ -101,7 +101,12 @@ class flock
if ($this->lock_fp)
{
- @flock($this->lock_fp, LOCK_EX);
+ if (@flock($this->lock_fp, LOCK_EX))
+ {
+ return (bool) $this->lock_fp;
+ } else {
+ throw new \phpbb\exception\http_exception(500, 'Failure while aqcuiring locks.');
+ }
}
return (bool) $this->lock_fp;