1 .. title:: clang-tidy - android-cloexec-open
6 A common source of security bugs is code that opens a file without using the
7 ``O_CLOEXEC`` flag. Without that flag, an opened sensitive file would remain
8 open across a fork+exec to a lower-privileged SELinux domain, leaking that
9 sensitive data. Open-like functions including ``open()``, ``openat()``, and
10 ``open64()`` should include ``O_CLOEXEC`` in their flags argument.
16 open("filename", O_RDWR);
17 open64("filename", O_RDWR);
18 openat(0, "filename", O_RDWR);
22 open("filename", O_RDWR | O_CLOEXEC);
23 open64("filename", O_RDWR | O_CLOEXEC);
24 openat(0, "filename", O_RDWR | O_CLOEXEC);