This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit c24cc5d584753d84158aad1c8ef1e27baf03d55f
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu May 7 00:59:42 2020 +0100
savemeta: Check file format version properly
Don't continue if we don't recognise the metadata file format version.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/savemeta.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index f8f3312..7dc506a 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -962,9 +962,12 @@ static int parse_header(char *buf, struct savemeta_header *smh)
{
struct savemeta_header *smh_be = (void *)buf;
- if (be32_to_cpu(smh_be->sh_magic) != SAVEMETA_MAGIC ||
- be32_to_cpu(smh_be->sh_format) > SAVEMETA_FORMAT) {
+ if (be32_to_cpu(smh_be->sh_magic) != SAVEMETA_MAGIC) {
printf("No valid file header found. Falling back to old format...\n");
+ return 1;
+ }
+ if (be32_to_cpu(smh_be->sh_format) > SAVEMETA_FORMAT) {
+ printf("This version of gfs2_edit is too old to restore this metadata
format.\n");
return -1;
}
smh->sh_magic = be32_to_cpu(smh_be->sh_magic);
@@ -1226,9 +1229,12 @@ static int restore_init(const char *path, struct metafd *mfd,
struct savemeta_he
return -1;
}
bp = restore_buf;
- if (parse_header(bp, smh) == 0) {
+ ret = parse_header(bp, smh);
+ if (ret == 0) {
bp = restore_buf + sizeof(*smh);
restore_off = sizeof(*smh);
+ } else if (ret == -1) {
+ return -1;
}
/* Scan for the position of the superblock. Required to support old formats(?). */
end = &restore_buf[256 + sizeof(struct saved_metablock) + sizeof(*sbmh)];
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
Show replies by thread