tCheck magic outside of unpack just like the other fields - dedup - deduplicating backup program
(HTM) git clone git://git.z3bra.org/dedup.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 758c94cb0be5e019637a9143e9f22601ab4a708b
(DIR) parent ed26c07028c2c908351edbba0152e59d3fe1fb88
(HTM) Author: sin <sin@2f30.org>
Date: Thu, 25 Apr 2019 17:44:32 +0100
Check magic outside of unpack just like the other fields
Diffstat:
M bstorage.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
---
(DIR) diff --git a/bstorage.c b/bstorage.c
t@@ -184,8 +184,6 @@ unpackbhdr(int fd, struct bhdr *bhdr)
&bhdr->nent);
assert(n == sizeof(buf));
- if (memcmp(bhdr->magic, BHDRMAGIC, NBHDRMAGIC) != 0)
- return -1;
return n;
}
t@@ -399,6 +397,13 @@ bsopen(struct bctx *bctx, char *path, int flags, int mode, struct bparam *bpar)
return -1;
}
+ /* Check magic */
+ if (memcmp(bhdr->magic, BHDRMAGIC, NBHDRMAGIC) != 0) {
+ free(sctx);
+ close(fd);
+ return -1;
+ }
+
/* If the major version is different, the format is incompatible */
if (((bhdr->flags >> VMAJSHIFT) & VMAJMASK) != VMAJ) {
free(sctx);