summaryrefslogtreecommitdiffstats
path: root/libmount/src/optstr.c
Commit message (Collapse)AuthorAgeFilesLines
* libmount: fix potential null pointer dereferenceSami Kerola2019-07-121-1/+3
| | | | | | | | | | This is false positive warning, but lets silence it so that if and when warnings crop up they are easy to notice and take seriously. libmount/src/optstr.c:354:29: warning: potential null pointer dereference [-Wnull-dereference] Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libmount: cleanup licenses sections in the filesKarel Zak2018-08-161-3/+8
| | | | | | | | | * add SPDX-License-Identifier (see https://spdx.org/licenses/) * add "This file part of libmount from util-linux project." * use proper text for LGPL-2.1-or-later * use the same texts everywhere Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: improve MS_REC usageKarel Zak2018-06-011-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | libmount allows to split one library (mount(8)) call to multiple mount(2) syscalls, for example --rbind --make-rslave in this case we have to be careful with MS_REC because the flag is applied to multiple operations. # strace -e mount mount --rbind --make-rslave /mnt/A /mnt/B Old version: mount("/mnt/A", "/mnt/B", 0x13ecac0, MS_MGC_VAL|MS_BIND, NULL) = 0 mount("none", "/mnt/B", NULL, MS_REC|MS_SLAVE, NULL) = 0 Fixed version: mount("/mnt/A", "/mnt/B", 0x1f22ac0, MS_MGC_VAL|MS_BIND|MS_REC, NULL) = 0 mount("none", "/mnt/B", NULL, MS_REC|MS_SLAVE, NULL) = 0 Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1584443 Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: fix reassigned values before old ones has been used [cppcheck]Sami Kerola2017-06-141-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libmount: support name=value for mnt_match_options()Karel Zak2016-12-201-5/+13
| | | | | | | | | $ findmnt --options mode=755 TARGET SOURCE FSTYPE OPTIONS /sys/fs/cgroup tmpfs tmpfs rw,nosuid,nodev,noexec,relatime,mode=755 /dev udev devtmpfs rw,relatime,size=1983516k,nr_inodes=495879,mode=755 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: reimplement mnt_match_options()Karel Zak2016-12-201-0/+79
| | | | | | | | Let's use optstr.c functions to parse pattern and options strings. It's more robust that the old original mount(8) code and it supports quotes in the options strings. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: Preserve empty string value in optstr parsingFilipe Brandenburger2016-08-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recent mount (since the switch to libmount in v2.22) drops the '=' in mount options that are set to an empty value. For example, the command line below will be affected: # mount -o rw,myopt='' -t tmpfs tmpfs /mnt/tmp Fix that by preserving an empty string in the options passed to the mount(2) syscall when they are present on the command line. Add test cases to ensure empty string handling is working as expected and in order to prevent regressions in the future. Also tested manually by stracing mount commands (on a kernel which accepts a special extra option, for testing purposes.) Before this commit: # strace -e mount ./mount -t tmpfs -o rw,myopt='' tmpfs /mnt/tmp mount("tmpfs", "/mnt/tmp", "tmpfs", MS_MGC_VAL, "myarg") = -1 EINVAL (Invalid argument) After this commit: # strace -e mount ./mount -t tmpfs -o rw,myopt='' tmpfs /mnt/tmp mount("tmpfs", "/mnt/tmp", "tmpfs", MS_MGC_VAL, "myopt=") = 0 All test cases pass, including newly added test cases. Also checked them with valgrind using: $ tests/run.sh --memcheck libmount/optstr Fixes #332. Signed-off-by: Filipe Brandenburger <filbranden@google.com>
* tests: fix compiler warnings [-Wmissing-prototypes]Ruediger Meier2016-02-231-10/+10
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libmount: fix uid= and gid= translationKarel Zak2015-10-121-11/+14
| | | | | | | | | | | | | | | | | | | | | | | The current libmount version returns error when no able to convert username/groupname to uid/git. # mount mount /dev/sda1 /mnt/test -o uid=ignore # mount: failed to parse mount options This is regression, the original mount(8) has ignored possible unknown user/group names and the option has been used unconverted (with the original value). For example UDF kernel driver depends on this behavior and "uid=ignore" (or "forgot") is a valid mount option. Fixed version (unit test): ./test_mount_optstr --fix uid=kzak,gid=forgot,aaa,bbb optstr: uid=kzak,gid=forgot,aaa,bbb fixed: uid=1000,gid=forgot,aaa,bbb Reported-By: Anthony DeRobertis <anthony@derobert.net> Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=801527 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix typo in mnt_optstr_prepend_option()Karel Zak2015-08-051-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: variable dereferenced before check [smatch scan]Karel Zak2015-08-051-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: remove assert(arg) from public functionsKarel Zak2015-02-161-23/+13Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: use new debug functionsKarel Zak2014-03-211-10/+10
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: Set each optstr's to NULL if failedNamhyung Kim2013-09-261-3/+9
| | | | | | | | When mnt_split_optstr() failed in the middle, vfs, fs, user optstr's are freed but not reset. It can lead to double frees at the end of mnt_fs_{ap,pre}pend_options(). Signed-off-by: Namhyung Kim <namhyung@gmail.com>
* libmount: fix typosOndrej Oprala2013-08-051-48/+48
| | | | Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
* libmount: more robust options string parsingKarel Zak2013-05-301-2/+2
| | | | | | | | | # mount -o=rw /dev/sdb /mnt/test mount: libmount/src/optmap.c:212: mnt_optmap_get_entry: Assertion `namelen' failed. Aborted (core dumped) Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=968786 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix mount.nfs segfault, rely on assert() rather than on nonnullKarel Zak2013-04-121-3/+23
| | | | | | | | | | | | | | | | | We use mnt_optstr_append_option(&o, mnt_fs_get_vfs_options(fs), NULL); in mount.nfs, unfortunately mnt_optstr_append_option() has been marked ass nonnull(1, 2). That's wrong because append and prepend should robust enough to accept NULL as option name. The patch also removes almost all __attribute__((nonnull). It seems better to rely on assert() to have usable feedback. In many cases (nonnull) is premature optimization for the library. This attribute makes sense for things like strlen() or so... Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=948274 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix __mnt_optstr_append_option() nonull attribute [coverity scan]Karel Zak2013-03-271-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: ignore name=value if only 'name' is expectedKarel Zak2013-02-281-1/+21
| | | | | | | | | | | | For example mount /srv/www /mnt -o rw,group=woven,dev,suid the group= should not be interpreted as userspace mount option, because umount(8) expects 'group' (without =<value>). Reported-by: Jan Engelhardt <jengelh@inai.de> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: clean nonnull attribute usageKarel Zak2012-12-041-2/+4
| | | | | | | | | | - use __attribute__((nonnull) for functions where we not able to return an return code ("is", "has" and some "get" functions). - use __attribute__((nonnull) for small functions where we always modify any of the function argument (some mnt_optstr_* functions) Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add mnt_optstr_deduplicate_option()Karel Zak2012-08-011-0/+61
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: improve ifdef HAVE_LIBSELINUX stuffKarel Zak2012-06-191-2/+11
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* Merge branch '2012wk23' of git://github.com/kerolasa/lelux-utiliteetitKarel Zak2012-06-151-1/+4
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * '2012wk23' of git://github.com/kerolasa/lelux-utiliteetit: lsblk: use blkdev_scsi_type_to_name() blkdev: add blkdev_scsi_type_to_name() wipefs: use symbolic value for markup mode eject: inform if CD-ROM drive is not ready docs: clean up partx.8 manual include: fix void pointer arithmetics warnings sysfs: fix printf format warnings build: fix unused parameter warnings build: fix redundant redeclaration warnings include: fix spurious list.h warnings uuidd: use output redirection which works [checkbashisms] blkid: fix realloc memory leak [cppcheck] setarch: do not use -1 as array index [cppcheck]
| * build: fix unused parameter warningsSami Kerola2012-06-111-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pager.c:203:14: warning: unused parameter 'argc' [-Wunused-parameter] pager.c:203:26: warning: unused parameter 'argv' [-Wunused-parameter] randutils.c:108:14: warning: unused parameter 'argc' [-Wunused-parameter] randutils.c:108:26: warning: unused parameter 'argv' [-Wunused-parameter] optstr.c:774:37: warning: unused parameter 'optstr' [-Wunused-parameter] optstr.c:774:51: warning: unused parameter 'value' [-Wunused-parameter] optstr.c:774:65: warning: unused parameter 'valsz' [-Wunused-parameter] optstr.c:774:79: warning: unused parameter 'next' [-Wunused-parameter] Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* | libmount: make some string operations more robustKarel Zak2012-06-151-1/+1
| | | | | | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* | libmount: fix read before allocated bufferPetr Uzel2012-06-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | valgrind --leak-check=full ./sys-utils/mount -t cifs //127.0.0.1/users /mnt/smb -o user=root,password=linux .... ==21359== Invalid read of size 1 ==21359== at 0x415AC6: mnt_optstr_remove_option_at (optstr.c:310) ==21359== by 0x416358: mnt_optstr_apply_flags (optstr.c:716) ==21359== by 0x40DFBF: mnt_context_prepare_mount (context_mount.c:86) ==21359== by 0x40EB5A: mnt_context_mount (context_mount.c:782) ==21359== by 0x4058B0: main (mount.c:918) ==21359== Address 0x51cd5bf is 1 bytes before a block of size 10 alloc'd ==21359== at 0x4C297CD: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==21359== by 0x4C29957: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==21359== by 0x415780: __mnt_optstr_append_option (optstr.c:188) ==21359== by 0x412822: mnt_fs_append_options (fs.c:764) ==21359== by 0x409288: mnt_context_append_options (context.c:733) ==21359== by 0x4053F0: main (mount.c:776) Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* | libmount: don't use nosuid,noexec,nodev for cifs user=fooKarel Zak2012-06-141-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mount -t cifs //127.0.0.1/users /mnt/smb -o user=root,password=linux is incorrectly translated to mount.cifs -o noexec,nosuid,nodev,user=root,password=linux ... The command mount(8) should be sensitive to "user" (without "=<name>") only. The correct cifs command line is: mount.cifs -o user=root,password=linux Addresses: https://bugzilla.novell.com/show_bug.cgi?id=766157 Signed-off-by: Karel Zak <kzak@redhat.com>
* | libmount: don't generate empty option stringsKarel Zak2012-06-141-1/+3
|/ | | | | | | | | | | | mount -t foo something /mnt/test -o user=root,password=linux generates "rw,noexec,nosuid,nodev,password=linux,,user=root" options string for /sbin/mount.foo, the ",," is incorrect. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: trim leading commas from each options stringDave Reisner2012-06-051-0/+5
| | | | | | | | | | | Fixes a bug in option string parsing wherein a line such as: ro,relatime,,nosuid,nodev Will be seen as only the tokens "ro" and "relatime" after the parser encounters a zero length (and erroneously declared NULL) option. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
* libmount: cleanup docsKarel Zak2012-02-221-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix buffer overflow and leaks in testsKarel Zak2012-01-261-1/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix compiler warnings [-Wsign-compare]Karel Zak2012-01-171-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: ignore "defaults" mount optionKarel Zak2012-01-171-1/+3
| | | | | | ... thanks to regression test! Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix MS_BIND|MS_REC usage, improve some bitwise operationsKarel Zak2012-01-161-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: allow to toggle ro/rw and mount againKarel Zak2012-01-131-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix trivial typos in debugging outputPetr Uzel2011-11-091-1/+1
| | | | Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* libmount: remove unnecessary includes, mask API as stableKarel Zak2011-07-251-7/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: clean up docsKarel Zak2011-07-251-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: cleanup docsKarel Zak2011-07-231-2/+1Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add support for mount -aKarel Zak2011-06-231-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: use top-level directory for libmount rather than shlibs/mountKarel Zak2011-06-091-0/+1224
Signed-off-by: Karel Zak <kzak@redhat.com>