summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-02 15:40:12 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-02 15:40:12 +0200
commit16b5b997d78e3d37a93701f9f32f91ae33ebb8fe (patch)
tree3436a333b81fab543f0899d5bb12a9689f57e2dc
parent402fc5a6000bf0ec12f05d4aa2b3e250ec85a60a (diff)
Fix potential double free of xattr reader id_block_starts
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--lib/sqfs/xattr_reader.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/sqfs/xattr_reader.c b/lib/sqfs/xattr_reader.c
index 4383e89..42a7e51 100644
--- a/lib/sqfs/xattr_reader.c
+++ b/lib/sqfs/xattr_reader.c
@@ -64,8 +64,7 @@ static int get_id_block_locations(xattr_reader_t *xr, int sqfsfd,
super->xattr_id_table_start + sizeof(idtbl),
sqfsfd, xr->id_block_starts,
sizeof(xr->id_block_starts[0]) * xr->num_id_blocks)) {
- free(xr->id_block_starts);
- return -1;
+ goto fail;
}
for (i = 0; i < xr->num_id_blocks; ++i) {
@@ -74,12 +73,15 @@ static int get_id_block_locations(xattr_reader_t *xr, int sqfsfd,
if (xr->id_block_starts[i] > super->bytes_used) {
fputs("found xattr ID block that is past "
"end of filesystem\n", stderr);
- free(xr->id_block_starts);
- return -1;
+ goto fail;
}
}
return 0;
+fail:
+ free(xr->id_block_starts);
+ xr->id_block_starts = NULL;
+ return -1;
}
static int get_xattr_desc(xattr_reader_t *xr, uint32_t idx,