libext2fs: fix unexpected NULL variable
commit794983ac1a98abd5124407a86f929fb5ea9acd07
authorLukas Czerner <lczerner@redhat.com>
Fri, 6 Aug 2021 09:58:16 +0000 (6 11:58 +0200)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 10 Aug 2021 15:01:06 +0000 (10 11:01 -0400)
tree82f2a5c2e8c08a5c041f5b9ee62f687499340cf3
parent20ce4c2cc5ec64db165218497cc1472dcefa6d28
libext2fs: fix unexpected NULL variable

The ext2fs_check_mount_point() function can be called with mtpt being
NULL as for example from ext2fs_check_if_mounted(). However in the
is_swap_device condition we use the mtpt in strncpy without checking
whether it is non-null first.

This should not be a problem on linux since the previous attempt to open
the device exclusively would have prevented us from ever reaching the
problematic strncpy. However it's still a bug and can cause problems on
other systems, fix it by conditioning strncpy on mtpt not being null.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/ismounted.c