aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Anderson <dvander@google.com>2018-03-02 15:38:38 -0800
committerTheodore Ts'o <tytso@mit.edu>2018-07-20 18:49:35 -0400
commit4eca2aef6a8a0e7678afb76c1eda1756c039c481 (patch)
treeb689d89c48a974410f0479a0aa800d312055d581
parent59c2913cb4e36e7090e12712122c6c24f0cd2a72 (diff)
downloade2fsprogs-4eca2aef6a8a0e7678afb76c1eda1756c039c481.tar.gz
AOSP: e2fsdroid: Fix crash with invalid command line args
If a sparse file fails to load, an inconsistent channel pointer will be returned, causing e2fsdroid to crash on exit. Signed-off-by: Theodore Ts'o <tytso@mit.edu> Bug: 64109868 Change-Id: If1606c7c49d5569323db5b5fce4826f24ba76383 From AOSP commit: 0f31d29a968eed6dc3c96eb47fd34e8608a2580c
-rw-r--r--lib/ext2fs/sparse_io.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/ext2fs/sparse_io.c b/lib/ext2fs/sparse_io.c
index d0828a81..5e0e2cd9 100644
--- a/lib/ext2fs/sparse_io.c
+++ b/lib/ext2fs/sparse_io.c
@@ -185,14 +185,22 @@ err_params:
static errcode_t sparse_open_channel(struct sparse_io_params *sparse_params,
int flags, io_channel *channel)
{
+ errcode_t retval;
io_channel io;
io = calloc(1, sizeof(struct struct_io_channel));
io->magic = EXT2_ET_MAGIC_IO_CHANNEL;
io->block_size = 0;
io->refcount = 1;
+
+ retval = io_manager_configure(sparse_params, flags, io);
+ if (retval) {
+ free(io);
+ return retval;
+ }
+
*channel = io;
- return io_manager_configure(sparse_params, flags, io);
+ return 0;
}
static errcode_t read_sparse_argv(const char *name, bool is_fd,