Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trim trailing '\0's inserted by libselinux.
libselinux has an off-by-one that causes it to pass the trailing '\0' to the kernel as if it's part of the security context, and the kernel dutifully hands it back, since it's an uninterpreted byte array as far as the kernel is concerned. libselinux accidentally hides this bug by treating it as a C string and calling strdup(), but debuggerd doesn't because it reads the file into a std::string. We could switch to libselinux's getcon()/getpidcon(), but (a) libselinux is awful (see above) and (b) not currently accessible to apexes (and it doesn't seem like a great idea to make it accessible). So just manually drop the last byte from the context we read ourselves, if it happens to be a '\0'. Bug: android/ndk#1993 Test: treehugger Change-Id: I8e7605ac5e618007a8da635cb6f45b0778dc167c
- Loading branch information