summaryrefslogtreecommitdiffstats
path: root/src/util/mmap_cache.h
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2013-01-07 10:34:48 +0100
committerJakub Hrozek <jhrozek@redhat.com>2013-01-07 17:35:13 +0100
commit31c47cacc7f9453153e57319474909d23122883f (patch)
treed59cbc40a2e7183d6d49f3786d760143611e9c8b /src/util/mmap_cache.h
parent528dd4ca82de4f4c2030ae22b723267ebc0d42e7 (diff)
downloadsssd-31c47cacc7f9453153e57319474909d23122883f.tar.gz
sssd-31c47cacc7f9453153e57319474909d23122883f.tar.xz
sssd-31c47cacc7f9453153e57319474909d23122883f.zip
memcache: add macro that validates record length
Diffstat (limited to 'src/util/mmap_cache.h')
-rw-r--r--src/util/mmap_cache.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/util/mmap_cache.h b/src/util/mmap_cache.h
index 407eeea69..1f99c758d 100644
--- a/src/util/mmap_cache.h
+++ b/src/util/mmap_cache.h
@@ -70,6 +70,12 @@ typedef uint32_t rel_ptr_t;
#define MC_VALID_BARRIER(val) (((val) & 0xff000000) == 0xf0000000)
+#define MC_CHECK_RECORD_LENGTH(mc_ctx, rec) \
+ ((rec)->len >= MC_HEADER_SIZE && (rec)->len != MC_INVALID_VAL32 \
+ && ((rec)->len <= ((mc_ctx)->dt_size \
+ - MC_PTR_DIFF(rec, (mc_ctx)->data_table))))
+
+
#define SSS_MC_MAJOR_VNO 0
#define SSS_MC_MINOR_VNO 4