]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1488 in SNORT/snort3 from ~KETJEN/snort3:lru_cache_changes to...
authorMichael Altizer (mialtize) <mialtize@cisco.com>
Wed, 23 Jan 2019 01:07:54 +0000 (20:07 -0500)
committerMichael Altizer (mialtize) <mialtize@cisco.com>
Wed, 23 Jan 2019 01:07:54 +0000 (20:07 -0500)
Squashed commit of the following:

commit a46e75f30321724c22d3cb9d47e362664c60c029
Author: ketjen <ketjen@cisco.com>
Date:   Fri Jan 11 18:58:32 2019 -0800

    hash: Added lru_cache_shared.h to HASH_INCLUDES

commit 5fbf496e9ecffd0e4b5d8d6e511b2c210f6b3e74
Author: ketjen <ketjen@cisco.com>
Date:   Fri Jan 11 18:58:00 2019 -0800

    hash: Moved list_iter assignment inside to avoid improper memory access
    in LruCacheShared

src/hash/CMakeLists.txt
src/hash/lru_cache_shared.h

index 99b23278fca05b7737e877caf1609f2a28f6fee8..f21b36c5b6e4f62059e17bf7f76078560992574b 100644 (file)
@@ -3,13 +3,13 @@ set (HASH_INCLUDES
     hashes.h
     ghash.h 
     xhash.h 
-    hashfcn.h 
+    hashfcn.h
+    lru_cache_shared.h
 )
 
 add_library( hash OBJECT
     ${HASH_INCLUDES}
     hashes.cc
-    lru_cache_shared.h
     lru_cache_shared.cc
     ghash.cc 
     hashfcn.cc 
index c7625e51f6949938716c7b34acb9f6b40bd758b7..0ea20de9a22c3391838ebfb2f3ddcb846bc68191 100644 (file)
@@ -155,9 +155,9 @@ bool LruCacheShared<Key, Data, Hash>::set_max_size(size_t newsize)
     std::lock_guard<std::mutex> cache_lock(cache_mutex);
 
     //  Remove the oldest entries if we have to reduce cache size.
-    list_iter=list.end();
     while (current_size > newsize)
     {
+        list_iter = list.end();
         --list_iter;
         current_size--;
         map.erase(list_iter->first);