|
|
f239de |
From 92d055879d510a1a51315301ea788445cd11aacb Mon Sep 17 00:00:00 2001
|
|
|
f239de |
From: Lukas Czerner <lczerner@redhat.com>
|
|
|
f239de |
Date: Fri, 6 Aug 2021 11:58:16 +0200
|
|
|
f239de |
Subject: [PATCH 40/46] libext2fs: fix unexpected NULL variable
|
|
|
f239de |
Content-Type: text/plain
|
|
|
f239de |
|
|
|
f239de |
The ext2fs_check_mount_point() function can be called with mtpt being
|
|
|
f239de |
NULL as for example from ext2fs_check_if_mounted(). However in the
|
|
|
f239de |
is_swap_device condition we use the mtpt in strncpy without checking
|
|
|
f239de |
whether it is non-null first.
|
|
|
f239de |
|
|
|
f239de |
This should not be a problem on linux since the previous attempt to open
|
|
|
f239de |
the device exclusively would have prevented us from ever reaching the
|
|
|
f239de |
problematic strncpy. However it's still a bug and can cause problems on
|
|
|
f239de |
other systems, fix it by conditioning strncpy on mtpt not being null.
|
|
|
f239de |
|
|
|
f239de |
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
|
|
|
f239de |
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
|
|
|
f239de |
---
|
|
|
f239de |
lib/ext2fs/ismounted.c | 3 ++-
|
|
|
f239de |
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
f239de |
|
|
|
f239de |
diff --git a/lib/ext2fs/ismounted.c b/lib/ext2fs/ismounted.c
|
|
|
f239de |
index 46d330d9..c28475d4 100644
|
|
|
f239de |
--- a/lib/ext2fs/ismounted.c
|
|
|
f239de |
+++ b/lib/ext2fs/ismounted.c
|
|
|
f239de |
@@ -393,7 +393,8 @@ errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags,
|
|
|
f239de |
|
|
|
f239de |
if (is_swap_device(device)) {
|
|
|
f239de |
*mount_flags = EXT2_MF_MOUNTED | EXT2_MF_SWAP;
|
|
|
f239de |
- strncpy(mtpt, "<swap>", mtlen);
|
|
|
f239de |
+ if (mtpt)
|
|
|
f239de |
+ strncpy(mtpt, "<swap>", mtlen);
|
|
|
f239de |
} else {
|
|
|
f239de |
#ifdef HAVE_SETMNTENT
|
|
|
f239de |
retval = check_mntent(device, mount_flags, mtpt, mtlen);
|
|
|
f239de |
--
|
|
|
f239de |
2.35.1
|
|
|
f239de |
|