capability: introduce CAP_TO_MASK_CORRECTED() macro replacing CAP_TO_MASK()
authorLennart Poettering <lennart@poettering.net>
Wed, 10 Oct 2018 09:07:54 +0000 (11:07 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 10 Oct 2018 09:11:48 +0000 (11:11 +0200)
commit5f00c5684f96c93a22840f7241ee444b9a632b1e
tree47891f18b69aa3943668e2aeede589165f793cf2
parentca92fe36e07d0d495baef1f860d66925bc0dc165
capability: introduce CAP_TO_MASK_CORRECTED() macro replacing CAP_TO_MASK()

linux/capability.h's CAP_TO_MASK potentially shifts a signed int "1"
(i.e. 32bit wide) left by 31 which means it becomes negative. That's
just weird, and ubsan complains about it. Let's introduce our own macro
CAP_TO_MASK_CORRECTED which doesn't fall into this trap, and make use of
it.

Fixes: #10347
src/basic/capability-util.h
src/libsystemd/sd-bus/bus-creds.c