diff options
author | Simo Sorce <simo@redhat.com> | 2012-12-20 04:10:25 +0000 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2012-12-20 19:55:02 +0100 |
commit | 6acf7c92ab38ad388295b2d57cc97c4598aa95cc (patch) | |
tree | 2dae4cb5af4b0e62ff9c95a5b8ee1f801da1233c /src/util | |
parent | da4c23b6670adb45f71cf51aaeca8df30c2144be (diff) | |
download | sssd-6acf7c92ab38ad388295b2d57cc97c4598aa95cc.tar.gz sssd-6acf7c92ab38ad388295b2d57cc97c4598aa95cc.tar.bz2 sssd-6acf7c92ab38ad388295b2d57cc97c4598aa95cc.zip |
Carefully check records when forcibly invalidating
We should never try to invalidate an already invalid record as
internal pointers will not be consistent. Carefully test that the
record really is valid when we are fishing for free space, and
properly invalidate records or return a fatal error if something
goes wrong.
In order to make the code more robust always invalidate the whole
data space on initialization by setting all bits to 1, and make sure
to invalidate the whole last allocated slot by converting rec->len to
the number of slots instead of just the space used.
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/mmap_cache.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/util/mmap_cache.h b/src/util/mmap_cache.h index b3dac6ee..407eeea6 100644 --- a/src/util/mmap_cache.h +++ b/src/util/mmap_cache.h @@ -47,8 +47,10 @@ typedef uint32_t rel_ptr_t; #define MC_PTR_ADD(ptr, bytes) (void *)((uint8_t *)(ptr) + (bytes)) #define MC_PTR_DIFF(ptr, base) ((uint8_t *)(ptr) - (uint8_t *)(base)) -#define MC_INVALID_PTR (void *)0xffffffff -#define MC_INVALID_VAL 0xffffffff +#define MC_INVALID_VAL64 ((uint64_t)-1) +#define MC_INVALID_VAL32 ((uint32_t)-1) +#define MC_INVALID_VAL8 ((uint8_t)-1) +#define MC_INVALID_VAL MC_INVALID_VAL32 /* * 32 seem a good compromise for slot size |