e2fsprogs/6001-AOSP-e2fsdroid-Fix-crash-with-invalid-command-line-a.patch
2019-09-30 10:37:40 -04:00

50 lines
1.3 KiB
Diff

From 4eca2aef6a8a0e7678afb76c1eda1756c039c481 Mon Sep 17 00:00:00 2001
From: David Anderson <dvander@google.com>
Date: Fri, 2 Mar 2018 15:38:38 -0800
Subject: [PATCH 004/131] 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
---
lib/ext2fs/sparse_io.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
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,
--
1.8.3.1