]> git.ipfire.org Git - thirdparty/systemd.git/commit
mountpoint-util: fix hosed overflow check
authorLennart Poettering <lennart@poettering.net>
Fri, 14 Apr 2023 11:05:29 +0000 (13:05 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 14 Apr 2023 11:15:39 +0000 (13:15 +0200)
commit524ea5852a7e6e85317ce4dd66877b7bcd11f982
treeaa24e711c299d4619a019a9ab06d269b5a5d4668
parent92851defbd9ec1b4216b01d55e36fccc4b1b5dc6
mountpoint-util: fix hosed overflow check

The overflow check was hosed in two ways: overflows in C are undefined,
hence gcc was free to just optimize the whole thing away. We need to
catch overflows before we run into them, not after.

It checked for an overflow against size_t, but the field we need to
write this in is unsigned. i.e. typically 32bit rather than 64bit. Hence
check for the right maximum.

(The whole check is paranoia anyway, the kernel really shouldn't return
values that would induce an overflow, but you never know, the syscall
turned out to be problematic in so many other ways, hence let's stick to
this.)
src/basic/mountpoint-util.c