e2fsprogs/misc
Lukas Czerner 18ebcf26f4 e2fsprogs: fix device name parsing to resolve names containing '='
Currently in varisous e2fsprogs tools, most notably tune2fs and e2fsck
we will get the device name by passing the user provided string into
blkid_get_devname(). This library function however is primarily intended
for parsing "NAME=value" tokens. It will return the device matching the
specified token, NULL if nothing is found, or copy of the string if it's
not in "NAME=value" format.

However in case where we're passing in a file name that contains an
equal sign blkid_get_devname() will treat it as a token and will attempt
to find the device with the match. Likely finding nothing.

Fix it by checking existence of the file first and then attempt to call
blkid_get_devname(). In case of a collision, notify the user and
automatically prefer the one returned by blkid_get_devname(). Otherwise
return either the existing file, or NULL.

We do it this way to avoid some existing file in working directory (for
example LABEL=volume-name) masking an actual device containing the
matchin LABEL. User can specify full, or relative path (e.g.
./LABEL=volume-name) to make sure the file is used instead.

Link: https://lore.kernel.org/r/20220812130122.69468-1-lczerner@redhat.com
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reported-by: Daniel Ng <danielng@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2022-08-12 22:32:14 -04:00
..
Android.bp AOSP: Move system_shared_libs into target.bionic clause 2021-07-27 12:31:55 -04:00
badblocks.8.in Change "filesystem" to "file system" in the man pages 2021-08-15 19:36:06 -04:00
badblocks.c Avoid potential NULL dereference when argv[0] 2022-08-11 23:49:14 -04:00
base_device.c Make sure test progams free all allocated memory 2016-11-11 23:15:56 -05:00
base_device.tst ChangeLog, Makefile.in, base_device.c, base_device.tst, fsck.c, fsck.h: 2000-12-03 06:33:56 +00:00
blkid.8.in Change "filesystem" to "file system" in the man pages 2021-08-15 19:36:06 -04:00
blkid.c AOSP: Ignore quotes in safe_print(). 2018-08-18 15:59:58 -04:00
chattr.1.in misc: fix chattr usage message for project ID 2022-05-02 20:22:02 -04:00
chattr.c misc: fix chattr usage message for project ID 2022-05-02 20:22:02 -04:00
check_fuzzer.c Add a program to test images provided by UBSAN fuzzing reports 2019-11-22 23:27:47 -05:00
create_inode.c misc: fix potential segmentation fault problem in scandir() 2021-07-15 23:43:37 -04:00
create_inode.h tests, mke2fs: add option to suppress xattr copying to fix f_extent_htree 2018-06-26 15:21:28 -04:00
dumpe2fs.8.in Change "filesystem" to "file system" in the man pages 2021-08-15 19:36:06 -04:00
dumpe2fs.c Avoid potential NULL dereference when argv[0] 2022-08-11 23:49:14 -04:00
e2freefrag.8.in Change "filesystem" to "file system" in the man pages 2021-08-15 19:36:06 -04:00
e2freefrag.c Fix clang warnings on architectures with a 64-bit long 2021-02-11 10:55:21 -05:00
e2freefrag.h e2freefrag: Improve output to include be more like xfs_db's freesp -s 2009-07-24 18:33:46 -04:00
e2fuzz.c Merge branch 'maint' into next 2021-01-23 01:05:43 -05:00
e2fuzz.sh e2fuzz: fuzz harder 2015-04-20 21:47:18 -04:00
e2image.8.in Change "filesystem" to "file system" in the man pages 2021-08-15 19:36:06 -04:00
e2image.c Avoid potential NULL dereference when argv[0] 2022-08-11 23:49:14 -04:00
e2initrd_helper.c e2fsprogs: fix device name parsing to resolve names containing '=' 2022-08-12 22:32:14 -04:00
e2label.8.in Change "filesystem" to "file system" in the man pages 2021-08-15 19:36:06 -04:00
e2label.c mmp: abstract out repeated 'sizeof(buf), buf' usage 2020-01-24 23:06:58 -05:00
e2mmpstatus.8.in Change "filesystem" to "file system" in the man pages 2021-08-15 19:36:06 -04:00
e2undo.8.in Change "filesystem" to "file system" in the man pages 2021-08-15 19:36:06 -04:00
e2undo.c Fix clang warnings on architectures with a 64-bit long 2021-02-11 10:55:21 -05:00
e4crypt.8.in Change "filesystem" to "file system" in the man pages 2021-08-15 19:36:06 -04:00
e4crypt.c e4crypt: if salt is explicitly provided to add_key, then use it 2020-10-01 16:51:46 -04:00
e4defrag.8.in Change "filesystem" to "file system" in the man pages 2021-08-15 19:36:06 -04:00
e4defrag.c Fix UBSAN if s_log_groups_per_flex is 31 2022-08-07 19:49:33 -04:00
ext4.5.in Change "filesystem" to "file system" in the man pages 2021-08-15 19:36:06 -04:00
filefrag.8.in Change "filesystem" to "file system" in the man pages 2021-08-15 19:36:06 -04:00
filefrag.c filefrag: minor usability improvements 2021-04-02 16:04:38 -04:00
findfs.8.in Change "filesystem" to "file system" in the man pages 2021-08-15 19:36:06 -04:00
findsuper.c misc: replace remaining loff_t with ext2_loff_t 2021-02-22 21:53:53 -05:00
fsck.8.in Change "filesystem" to "file system" in the man pages 2021-08-15 19:36:06 -04:00
fsck.c e2fsprogs: fix device name parsing to resolve names containing '=' 2022-08-12 22:32:14 -04:00
fsck.h Fix typos in code comments and developer docs 2017-10-15 23:00:11 -04:00
fsmap.h e2freefrag: use GETFSMAP on mounted filesystems 2017-05-29 22:29:15 -04:00
fuse2fs.1.in fuse2fs: add a norecovery option which suppresses journal replay 2019-08-18 20:25:53 -04:00
fuse2fs.c Enable threaded support for e2fsprogs' applications. 2021-01-21 10:50:40 -05:00
ismounted.c misc: cleanup unused variables on MacOS 2012-12-29 17:28:37 -05:00
logsave.8.in Remove spaces at the end of man pages 2017-08-04 01:51:50 -04:00
logsave.c Fix typos in code comments and developer docs 2017-10-15 23:00:11 -04:00
lsattr.1.in Add missing information to various man pages and usage texts 2017-12-21 11:11:10 -05:00
lsattr.c Avoid potential NULL dereference when argv[0] 2022-08-11 23:49:14 -04:00
Makefile.in e2fsprogs: fix device name parsing to resolve names containing '=' 2022-08-12 22:32:14 -04:00
mk_hugefiles.c Fix clang warnings on architectures with a 64-bit long 2021-02-11 10:55:21 -05:00
mke2fs-hurd.conf Add "big" and "huge" types to mke2fs.conf 2011-10-03 23:46:17 -04:00
mke2fs.8.in Change "filesystem" to "file system" in the man pages 2021-08-15 19:36:06 -04:00
mke2fs.c mke2fs: allow the default creator os to be specified in /etc/mke2fs.conf 2021-08-15 18:58:35 -04:00
mke2fs.conf.5.in mke2fs.conf.5: fix spelling errors in man page 2021-12-29 21:33:27 -05:00
mke2fs.conf.in mke2fs: warn about missing y2038 support when formatting fresh ext4 fs 2021-08-14 15:10:42 -04:00
mke2fs.h mke2fs: add support to align hugefiles relative to beginning of the disk 2014-07-09 10:42:13 -04:00
mklost+found.8.in Change "filesystem" to "file system" in the man pages 2021-08-15 19:36:06 -04:00
mklost+found.c Fix gcc and clang warnings 2018-06-23 23:00:50 -04:00
partinfo.c partinfo: fix some build errors 2016-10-25 13:28:13 -04:00
profile-to-c.awk mke2fs: Escape double quotes when parsing mke2fs.conf 2021-01-19 23:56:20 -05:00
tune2fs.8.in Fix miscellaneous spelling errors in man pages, and release notes 2021-08-15 19:36:07 -04:00
tune2fs.c e2fsprogs: fix device name parsing to resolve names containing '=' 2022-08-12 22:32:14 -04:00
tune2fs.h Fix typos in code comments and developer docs 2017-10-15 23:00:11 -04:00
util.c e2fsprogs: fix device name parsing to resolve names containing '=' 2022-08-12 22:32:14 -04:00
util.h Make userspace tools number of fast commits blocks aware 2021-01-21 10:57:22 -05:00
uuidd.8.in Fix the pathname of /var/lib/uuidd/uuidd.pid in uuidd man page. 2008-01-19 18:13:14 -05:00
uuidd.c Move the check_plausibility() function from misc to lib/support 2015-07-12 22:01:17 -04:00
uuidd.rc Add uuidd daemon to prevent duplicate time-based UUID's 2007-12-16 17:28:46 -05:00
uuidgen.1.in Remove spaces at the end of man pages 2017-08-04 01:51:50 -04:00
uuidgen.c Move the check_plausibility() function from misc to lib/support 2015-07-12 22:01:17 -04:00