Commit Graph

20 Commits

Author SHA1 Message Date
Karel Zak 40f8c5e47e include: add some missing licence stuff to header files
It's mostly wrappers for compatibility and another trivial stuff etc.
Let's keep it as public domain to make it more portable to LGPL, GPL
and BSD code.

Signed-off-by: Karel Zak <kzak@redhat.com>
CC: Sami Kerola <kerolasa@iki.fi>
CC: Ruediger Meier <ruediger.meier@ga-group.nl>
2020-01-13 10:39:52 +01:00
Sami Kerola 4f807791ee
lib/mangle: fix possible null pointer dereference [cppcheck]
Fix effects code that is used when testing util-linux, so quite low impact.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-18 22:09:25 +01:00
Karel Zak 36fcefa651 libmount: don't use sscanf() for fstab parsing
Addresses: https://github.com/karelzak/util-linux/issues/780
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-08 13:34:47 +02:00
Karel Zak 78c66fc61d lib/mangle: const quialifier cleanup
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 15:31:42 +02:00
Karel Zak 61b9233995 lib/mangle: return size of the decoded buffer
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-01 15:33:04 +01:00
Karel Zak e8f7acb0d3 lib: use unique ifdefs for tests
Let's use unique TEST_PROGRAM_<NAME> ifdefs to make build system more
robust.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-01-04 11:44:37 +01:00
Karel Zak f369387731 lib/mangle: remove unused variable
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-08-13 21:57:34 +02:00
Karel Zak 096db1ead1 libmount: fix unmangle code
old version:
  /mnt/ugly/te\134st\134 -> /mnt/ugly/te\st\134

fixed version:
  /mnt/ugly/te\134st\134 -> /mnt/ugly/te\st\

Reported-by: Naja Melan <najamelan@autistici.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-08-13 16:35:03 +02:00
Cong Wang a0b25068ab lib/mangle: fix a memory leak in the test case
Marek reported there is a memory leak in lib/mangle.c

  CC       mangle.o
mangle.c:160:9: warning: Memory is never released; potential leak of memory pointed to by 'ss'

This patch fixes it.

Reported-by: Marek Otahal <markotahal@gmail.com>
Cc: Karel Zak <kzak@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2012-06-21 08:21:43 +02:00
Dave Reisner ea178007eb lib/mangle: check for end of string on every iteration
Checking for the null byte at the end of the string only conditionally
leads to segfaults, evidenced by mount helpers crashing on writes to
/run/mount/utab. Simply check for the null on each iteration, and append
a null byte to the mangled string before breaking.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-05-15 11:32:24 +02:00
Karel Zak 95387b6696 lib/mangle: cleanup, add unhexmangle
* use strchr() rather than for()
 * small refactoring in mangle code
 * add un-hex-mangle

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-26 09:17:44 +02:00
Karel Zak edd1362f8c lib: [mangle.c] fix compiler warnings [-Wsign-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-01 12:18:22 +02:00
Karel Zak 6c7f688b1f umount: segfaults with inconsistent entry in /etc/fstab
Addresses: https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/726283
Reported-by: Greg Brockman <gdb@gregbrockman.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-04 14:44:29 +01:00
Fabian Groffen eb76ca98b0 build-sys: provide alternatives for err, errx, warn and warnx
Solaris lacks err, errx, warn and warnx.  This also means the err.h header
doesn't exist.  Removed err.h include from all files, and included err.h from
c.h instead if it exists, otherwise alternatives are provided.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
2011-02-14 17:45:24 +01:00
Karel Zak 5ac6a13327 libmount: cleanup mangle() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-03 12:28:47 +01:00
Karel Zak dd36965211 libmount: use better format for utab, improve bind mounts
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-03 12:28:46 +01:00
Karel Zak 8f3f6383a5 libmount: rewrite mountinfo/fstab parsers to use sscanf()
The old solution (without scanf()) was based on old code from
mount(8). It seems that the modern libc is able to provide all
necessary functionality by sscanf() and %ms directive.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-03 12:28:43 +01:00
Karel Zak 7a539b29af lib: fix mange() and unmangle() to handle NULL
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-03 12:28:40 +01:00
Karel Zak 3c5e4ef888 libmount: add unmangle/mangle() functions to API
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-03 12:28:40 +01:00
Karel Zak 21169393e3 lib: add mangle.c for mtab (fstab or swaps) encoding
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-10 23:54:11 +01:00