1.. title:: clang-tidy - android-cloexec-open 2 3android-cloexec-open 4==================== 5 6A 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 8open across a fork+exec to a lower-privileged SELinux domain, leaking that 9sensitive data. Open-like functions including ``open()``, ``openat()``, and 10``open64()`` should include ``O_CLOEXEC`` in their flags argument. 11 12Examples: 13 14.. code-block:: c++ 15 16 open("filename", O_RDWR); 17 open64("filename", O_RDWR); 18 openat(0, "filename", O_RDWR); 19 20 // becomes 21 22 open("filename", O_RDWR | O_CLOEXEC); 23 open64("filename", O_RDWR | O_CLOEXEC); 24 openat(0, "filename", O_RDWR | O_CLOEXEC); 25