Skip to content

Commit

Permalink
Protect against duplicate synckey in cache.
Browse files Browse the repository at this point in the history
This should never happen, synckeys should always be unique to
each collection. However, broken/corrupt clients may send the
wrong synckey/collection pair.
  • Loading branch information
mrubinsk committed Apr 10, 2016
1 parent b58b7b5 commit 09213da
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion framework/ActiveSync/lib/Horde/ActiveSync/State/Mongo.php
Expand Up @@ -278,7 +278,7 @@ protected function _loadState($type)
{
try {
$results = $this->_db->selectCollection(self::COLLECTION_STATE)->findOne(
array(self::MONGO_ID => $this->_syncKey),
array(self::MONGO_ID => $this->_syncKey, self::SYNC_FOLDERID => $this->_collection['id']),
array(self::SYNC_DATA, self::SYNC_DEVID, self::SYNC_MOD, self::SYNC_PENDING));
} catch (Exception $e) {
$this->_logger->err('Error in loading state from DB: ' . $e->getMessage());
Expand Down
2 changes: 1 addition & 1 deletion framework/ActiveSync/lib/Horde/ActiveSync/State/Sql.php
Expand Up @@ -227,7 +227,7 @@ protected function _loadState($type)
// Load the previous syncState from storage
try {
$results = $this->_db->selectOne('SELECT sync_data, sync_devid, sync_mod, sync_pending FROM '
. $this->_syncStateTable . ' WHERE sync_key = ?', array($this->_syncKey));
. $this->_syncStateTable . ' WHERE sync_key = ? AND sync_folderid = ?', array($this->_syncKey, $this->_collection['id']));
} catch (Horde_Db_Exception $e) {
$this->_logger->err(sprintf(
'[%s] %s',
Expand Down

0 comments on commit 09213da

Please sign in to comment.