aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzhanchengbin <zhanchengbin1@huawei.com>2021-12-31 15:42:17 +0800
committerTheodore Ts'o <tytso@mit.edu>2022-05-11 20:56:42 -0400
commited54397b414def44d8ef11b4e320d9809d5fa294 (patch)
treea8345ae7dfe46d775d10f0fd3d7c67766c512a19
parent1c966c9dffef7e823a020a2f3982e9b9b1953e8b (diff)
downloade2fsprogs-ed54397b414def44d8ef11b4e320d9809d5fa294.tar.gz
libsupport: avoid possible null dereference in quota_set_sb_inum()
If the quota type is invalid, quota_sb_inump will return NULL; this should not cause the program to crash. Link: https://lore.kernel.org/r/ee0b034c-71f3-63b7-a8de-d8e7760b9545@huawei.com Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--lib/support/mkquota.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/support/mkquota.c b/lib/support/mkquota.c
index 5de7c48d6..c89f89590 100644
--- a/lib/support/mkquota.c
+++ b/lib/support/mkquota.c
@@ -99,6 +99,8 @@ void quota_set_sb_inum(ext2_filsys fs, ext2_ino_t ino, enum quota_type qtype)
log_debug("setting quota ino in superblock: ino=%u, type=%d", ino,
qtype);
+ if (inump == NULL)
+ return;
*inump = ino;
ext2fs_mark_super_dirty(fs);
}