summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2020-11-09 14:45:57 -0800
committerVito Caputo <vcaputo@pengaru.com>2020-11-09 14:45:57 -0800
commitcca2f79dfeb492926bd41619bd2ef931f77d00da (patch)
treea6e6e7d29b11b05ea3884e6494a816228ba18b6d
parent42904eef310313eeed6f8d91d5306488fd016d2e (diff)
load_cache: treat invalid frame header as EOF
In preparation for posix_fallocate() pre-allocation of cache files, expect zeroes for the header when running off the end of valid data into the only allocated space, and handle gracefully as an EOF equivalent.
-rw-r--r--src/rmd_load_cache.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/rmd_load_cache.c b/src/rmd_load_cache.c
index 4ad1741..303cc3b 100644
--- a/src/rmd_load_cache.c
+++ b/src/rmd_load_cache.c
@@ -153,7 +153,10 @@ static int rmdReadFrame(CachedFrame *frame, CacheFile *icf)
static int read_header(FrameHeader *fheader, CacheFile *icf)
{
- return rmdCacheFileRead(icf, fheader, sizeof(FrameHeader)) == sizeof(FrameHeader);
+ if (!(rmdCacheFileRead(icf, fheader, sizeof(FrameHeader)) == sizeof(FrameHeader)))
+ return 0;
+
+ return !strncmp(fheader->frame_prefix, "FRAM", 4);
}
void *rmdLoadCache(ProgData *pdata)
© All Rights Reserved