diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-02-19 14:17:19 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-02-20 16:03:42 -0500 |
commit | 2fa4861ad5a203bff604cac660136834e3b70108 (patch) | |
tree | 890482030d556a19efd046c5b1b2171a8de30528 /src/core/dbus-device.c | |
parent | 0357fa0dcea7e6bd599fbd5b6aac6df9b6961c8e (diff) |
sd-device: replace lstat() + open() with open(O_NOFOLLOW)
Coverity was complaining about TOCTOU (CID #745806). Indeed, it seems better
to open the file and avoid the stat altogether:
- O_NOFOLLOW means we'll get ELOOP, which we can translate to EINVAL as before,
- similarly, open(O_WRONLY) on a directory will fail with EISDIR,
- and finally, it makes no sense to check access mode ourselves: just let
the kernel do it and propagate the error.
v2:
- fix memleak, don't clober input arg
Diffstat (limited to 'src/core/dbus-device.c')
0 files changed, 0 insertions, 0 deletions