From: David Anderson Date: Fri, 2 Mar 2018 23:38:38 +0000 (-0800) Subject: AOSP: e2fsdroid: Fix crash with invalid command line args X-Git-Tag: v1.44.4~32 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=4eca2aef6a8a0e7678afb76c1eda1756c039c481;p=tools%2Fe2fsprogs.git 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 Bug: 64109868 Change-Id: If1606c7c49d5569323db5b5fce4826f24ba76383 From AOSP commit: 0f31d29a968eed6dc3c96eb47fd34e8608a2580c --- diff --git a/lib/ext2fs/sparse_io.c b/lib/ext2fs/sparse_io.c index d0828a8..5e0e2cd 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,