`conf` as configuration_data() object can contain any datatype.
For `HAVE_FOO` variables this will be a `1` int to generate
`#define HAVE_FOO 1` or a `false` bool to generate `#undef HAVE_FOO`
in `conf.h`.
When retrieving and testing `HAVE_FOO` from `conf` it can be both types.
Newer versions of meson are unhappy about comparisions of int with
non-int
../meson.build:734: DEPRECATION: Project uses feature that was always broken, and is now deprecated since '1.2.0': int operations with non-int. It is not commutative and only worked because of leaky Python abstractions.
WARNING: Broken features used:
* 1.2.0: {'int operations with non-int'}
As both `int` and `bool` support a `.to_string()` method, we can use
that to convert them into a well-known type and compare that.
Unfortunately meson does not implement a way to determine the type of a
value.
A method `int.to_int()` would also have worked but does not exist.
This broken feature was actually first recognized in util-linux.
See #2312 and https://github.com/mesonbuild/meson/pull/11879.
Karel Zak [Wed, 4 Oct 2023 18:08:06 +0000 (20:08 +0200)]
Merge branch 'libblkid/align' of https://github.com/t-8ch/util-linux
* 'libblkid/align' of https://github.com/t-8ch/util-linux:
libblkid: (probe) remove chunking from blkid_probe_get_idmag()
libblkid: (probe) read data in chunks
swapon: (tests) abort test on failing commands
libblkid: reset errno before calling probefuncs
libfdisk: reset errno before calling read()
Karel Zak [Wed, 4 Oct 2023 17:35:26 +0000 (19:35 +0200)]
Merge branch 'ci/musl' of https://github.com/t-8ch/util-linux
* 'ci/musl' of https://github.com/t-8ch/util-linux:
ci: run full testsuite under musl libc
build-sys: only build col on glibc
lib/timeutils: don't use glibc strptime extension
Karel Zak [Mon, 2 Oct 2023 10:40:55 +0000 (12:40 +0200)]
Merge branch 'libblkid/drbd-simplify' of https://github.com/t-8ch/util-linux
* 'libblkid/drbd-simplify' of https://github.com/t-8ch/util-linux:
libblkid: (drbd) avoid unaligned accesses
include/c.h: add helpers for unaligned structure access
libblkid: (drbd) use magics
libblkid: (probe) allow superblock offset from end of device
libblkid: (cramfs) use magic hint
libblkid: (probe) add magic hint
libblkid: (drbd) validate size in standard minsz predicate
libblkid: (via_raid) validate size in standard minsz predicate
libblkid: (silicon_raid) validate size in standard minsz predicate
libblkid: (promise_raid) validate size in standard minsz predicate
libblkid: (nvidia_raid) validate size in standard minsz predicate
libblkid: (lsi_raid) validate size in standard minsz predicate
libblkid: (jmicron_raid) validate size in standard minsz predicate
libblkid: (isw_raid) validate size in standard minsz predicate
libblkid: (highpoint_raid) validate size in standard minsz predicate
libblkid: (ddf_raid) validate size in standard minsz predicate
libblkid: (adapted_raid) validate size in standard minsz predicate
libblkid: (probe) remove duplicate log
Karel Zak [Mon, 2 Oct 2023 10:40:38 +0000 (12:40 +0200)]
Merge branch 'analyzer2' of https://github.com/t-8ch/util-linux
* 'analyzer2' of https://github.com/t-8ch/util-linux:
libblkid: (probe) handle probe without chain gracefully
libsmartcols: (cell) consistently handle NULL argument
lib/idcache: always gracefully handle null cache
script-playutils: close filestream in case ignore_line() fails
lib/colors: correct documentation of colors_add_scheme()
treewide: use reallocarray to allocated memory that will be reallocated
Thomas Weißschuh [Sat, 30 Sep 2023 21:58:05 +0000 (23:58 +0200)]
libblkid: (drbd) use magics
Reuse more of the standard prober functionality.
This also avoids a potential unaligned access when comparing the
superblock magic as a number.
In case the superblock was already cached by a different loader the
return address may have been unaligned leading to undefined behavior.
Some functions allow passing NULL, some don't.
Even users internal to util-linux are passing NULL parameters to these
functions, even for ones where it is not allowed.
Unify the API. As there may be external users that rely on the
NULL-accepting behavior for some functions use it everywhere.
Thomas Weißschuh [Wed, 27 Sep 2023 20:04:40 +0000 (22:04 +0200)]
lib/colors: correct documentation of colors_add_scheme()
The function does not take ownership of its arguments and it does not
require those arguments to be heap-allocated.
In fact there is only one caller and it passed stack-allocated values.
Thomas Weißschuh [Mon, 25 Sep 2023 22:27:22 +0000 (00:27 +0200)]
libblkid: (ntfs) validate that sector_size is a power of two
The NTFS prober reads data based off an offset of the sector size.
If the sector size is unaligned and the read data is cached then other
probers can read unaligned values.
Sector sizes for NTFS actually only make sense as power-of-two so
validate that and as a sideeffect avoid the unaligned reads.
Also add the reproducer from OSS-Fuzz that found this issue.
Karel Zak [Mon, 25 Sep 2023 10:44:46 +0000 (12:44 +0200)]
Merge branch 'login-terminal' of https://github.com/stoeckmann/util-linux
* 'login-terminal' of https://github.com/stoeckmann/util-linux:
login: prevent undefined ioctl and tcsetattr calls
login: use correct terminal fd during setup
Karel Zak [Mon, 25 Sep 2023 10:35:48 +0000 (12:35 +0200)]
Merge branch 'timestamp' of https://github.com/t-8ch/util-linux
* 'timestamp' of https://github.com/t-8ch/util-linux:
lib/timeutils: (parse_timestamp_reference) report errors on overflow
lib/timeutils: print error if timestamp can't be parsed
lib/timeutils: test epoch timestamp
Karel Zak [Mon, 25 Sep 2023 10:22:54 +0000 (12:22 +0200)]
Merge branch 'lsfd--resolve-mqueue-nodev' of https://github.com/masatake/util-linux
* 'lsfd--resolve-mqueue-nodev' of https://github.com/masatake/util-linux:
lsfd: collect the device number for mqueue fs in the initialization stage
tests: (lsfd) show the entry for mqueue in /proc/self/mountinfo
Thomas Weißschuh [Fri, 22 Sep 2023 18:38:13 +0000 (20:38 +0200)]
ci: also use GCC 13 for sanitizer builds
Now that -Werror is not used anymore with -fsanitize the false-postives
are not a problem anymore and we get the better runtime checks of newer
sanitizers.
Thomas Weißschuh [Fri, 22 Sep 2023 09:19:24 +0000 (11:19 +0200)]
ci: don't combine -Werror and -fsanitize
As explained in [0]:
Note that sanitizers tend to increase the rate of false positive
warnings, most notably those around -Wmaybe-uninitialized. We recommend
against combining -Werror and [the use of] sanitizers.
login: prevent undefined ioctl and tcsetattr calls
Do not call tcsetattr if tcgetattr fails, because the content of
tt and ttt is undefined in that case.
Also do not just warn if ioctl fails, but also avoid calling it again
after tty has been re-opened.
I've solved this by setting struct variables to values which cannot be
valid at this point. If they do have these exact values, then the
calls will be prevented.
The function get_terminal_name iterates through standard file
descriptors until it finds a terminal. This means that it's not
guaranteed that STDIN_FILENO (i.e. 0) is actually a terminal.
Do not modify permissions on possible files. Instead, retrieve
the file descriptor which was used by get_terminal_name as well.
Proof of Concept (as root):
1. Create a temporary file with a mode different than TTYPERM.
```
install -m 700 /dev/null /tmp/test
ls -l /tmp/test
-rwx------ 1 root root 0 Sep 21 20:15 /tmp/test
```
2. Run login within a terminal with adjusted stdin.
```
login < /tmp/test
host login:
Hangup
```
3. Check permissions of input file.
```
ls -l /tmp/test
-rw------- 1 root root 0 Sep 21 20:15 /tmp/test
```