This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
The following commit(s) were added to refs/heads/andyp-sparse by this push:
new 465f107d gfs2_edit: Don't return an invalid pointer from restore_block()
465f107d is described below
commit 465f107d2844ee8a6d88c16d3575f6540aa361e4
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jun 16 08:12:51 2021 -0400
gfs2_edit: Don't return an invalid pointer from restore_block()
The restore buffer can be modified underneath us after the second call
to restore_buf_next() so grab the blk and siglen values out of the
buffer straight away instead of returning a pointer into it.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/savemeta.c | 28 +++++++++++-----------------
1 file changed, 11 insertions(+), 17 deletions(-)
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 22e5c71c..5ccc46a8 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -1215,36 +1215,33 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
exit(0);
}
-static char *restore_block(struct metafd *mfd, struct saved_metablock **svbp)
+static char *restore_block(struct metafd *mfd, uint64_t *blk, uint16_t *siglen)
{
struct saved_metablock *svb;
const char *errstr;
char *buf = NULL;
- uint16_t siglen;
- uint64_t blk;
svb = (struct saved_metablock *)(restore_buf_next(mfd, sizeof(*svb)));
if (svb == NULL)
goto nobuffer;
- blk = be64_to_cpu(svb->blk);
- siglen = be16_to_cpu(svb->siglen);
+ *blk = be64_to_cpu(svb->blk);
+ *siglen = be16_to_cpu(svb->siglen);
- if (sbd.fssize && blk >= sbd.fssize) {
+ if (sbd.fssize && *blk >= sbd.fssize) {
fprintf(stderr, "Error: File system is too small to restore this
metadata.\n");
fprintf(stderr, "File system is %"PRIu64" blocks. Restore block =
%"PRIu64"\n",
- sbd.fssize, blk);
+ sbd.fssize, *blk);
return NULL;
}
- if (siglen > sbd.sd_bsize) {
+ if (*siglen > sbd.sd_bsize) {
fprintf(stderr, "Bad record length: %u for block %"PRIu64"
(0x%"PRIx64").\n",
- siglen, blk, blk);
+ *siglen, *blk, *blk);
return NULL;
}
- buf = restore_buf_next(mfd, siglen);
+ buf = restore_buf_next(mfd, *siglen);
if (buf != NULL) {
- *svbp = svb;
return buf;
}
nobuffer:
@@ -1289,20 +1286,17 @@ static int restore_data(int fd, struct metafd *mfd, int
printonly)
}
while (TRUE) {
- struct saved_metablock *sm = NULL;
- unsigned siglen;
- uint64_t blk;
+ uint16_t siglen = 0;
+ uint64_t blk = 0;
char *bp;
- bp = restore_block(mfd, &sm);
+ bp = restore_block(mfd, &blk, &siglen);
if (bp == NULL && mfd->eof)
break;
if (bp == NULL) {
free(buf);
return -1;
}
- siglen = be16_to_cpu(sm->siglen);
- blk = be64_to_cpu(sm->blk);
if (printonly) {
if (printonly > 1 && printonly == blk) {
display_block_type(bp, blk, TRUE);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
Show replies by date