summaryrefslogtreecommitdiffstats
path: root/tests/fortify_test.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix poll/ppoll fortify test to avoid hanging in failed fortify clang test.Yabin Cui2015-02-041-2/+7
| | | | | Bug: 19220800 Change-Id: Ie75c640183c4a41a499556fefb4f824a134a5fb1
* Explicitly check that the reason fortify tests abort is fortify.Elliott Hughes2015-02-021-73/+65
| | | | Change-Id: I95291e2febf7b497c1d9f37fd7fa9acdd21e86a4
* Fortify poll and ppoll.Elliott Hughes2015-02-021-9/+13
| | | | | | | And remove the test for FD_ZERO fortification, which never made much sense anyway. Change-Id: Id1009c5298d461fa4722189e8ecaf22f0c529536
* make all bionic death tests not dumpableYabin Cui2014-11-061-82/+10
| | | | | | Bug: 18067305 Change-Id: Ia1ecacf47eddecc9bc58aaac779e0c218f463179
* Revert "cdefs.h: add artificial attribute to FORTIFY_SOURCE functions"Nick Kralevich2014-10-061-0/+27
| | | | | | | | | | | | | | | | | Broke the build. In file included from frameworks/rs/cpu_ref/rsCpuCore.cpp:36: system/core/include/cutils/properties.h:118:1: error: unknown attribute '__artificial__' ignored [-Werror,-Wunknown-attributes] __BIONIC_FORTIFY_INLINE ^ bionic/libc/include/sys/cdefs.h:537:110: note: expanded from macro '__BIONIC_FORTIFY_INLINE' #define __BIONIC_FORTIFY_INLINE extern __inline__ __always_inline __attribute__((gnu_inline)) __attribute__((__artificial__)) ^ 1 error generated. make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libRSCpuRef_intermediates/rsCpuCore.o] Error 1 This reverts commit 9b543ffeac216189cc8125f7624da9a8cbcbe2e4. Change-Id: I6a1198747505dcb402b722887c1bfbc3a628a8b8
* cdefs.h: add artificial attribute to FORTIFY_SOURCE functionsNick Kralevich2014-10-041-27/+0
| | | | | | | | | | | Otherwise the gcc compiler warning doesn't show up. Delete some unittests. These unittests no longer compile cleanly using -Wall -Werror, and rewriting them to compile cleanly isn't feasible. Bug: 17784968 Change-Id: I9bbdc7b6a1c2ac75754f5d0f90782e0dfae66721
* debuggerd: if PR_GET_DUMPABLE=0, don't ask for dumpingNick Kralevich2014-07-231-58/+74
| | | | | | | | | | | | | | | | | | | | | | | | PR_GET_DUMPABLE is used by an application to indicate whether or not core dumps / PTRACE_ATTACH should work. Security sensitive applications often set PR_SET_DUMPABLE to 0 to disable core dumps, to avoid leaking sensitive memory to persistent storage. Similarly, they also set PR_SET_DUMPABLE to zero to prevent PTRACE_ATTACH from working, again to avoid leaking the contents of sensitive memory. Honor PR_GET_DUMPABLE when connecting to debuggerd. If an application has said it doesn't want its memory dumped, then we shouldn't ask debuggerd to dump memory on its behalf. FORTIFY_SOURCE tests: Modify the fortify_source tests to set PR_SET_DUMPABLE=0. This reduces the total runtime of /data/nativetest/bionic-unit-tests/bionic-unit-tests32 from approx 53 seconds to 25 seconds. There's no need to connect to debuggerd when running these tests. Bug: 16513137 Change-Id: Idc7857b089f3545758f4d9b436b783d580fb653f
* Consistently use #if defined(__BIONIC__) in tests.Elliott Hughes2014-05-131-1/+1
| | | | | | | | I've also switched some tests to be positive rather than negative, because !defined is slightly harder to reason about and there are only two cases: bionic and glibc. Change-Id: I8d3ac40420ca5aead3e88c69cf293f267273c8ef
* Fix fallout from host GCC upgrade.Elliott Hughes2014-04-231-1/+6
| | | | | | I'll raise a bug for the FD_ISSET fortification; we should do better too. Change-Id: Id2bf277890ad06b010dc952e270d746714c2bea7
* Add stpcpy/stpncpy.Christopher Ferris2014-04-071-10/+110
| | | | | | | | | | | | | | Add tests for the above. Add the fortify implementations of __stpcpy_chk and __stpncpy_chk. Modify the strncpy test to cover more cases and use this template for stpncpy. Add all of the fortify test cases. Bug: 13746695 Change-Id: I8c0f0d4991a878b8e8734fff12c8b73b07fdd344
* Make sure that the same tests are on all platforms.Christopher Ferris2014-02-061-7/+65
| | | | | | | | | | | | | | | | In order to be able to generate a list of tests for cts, the same set of tests must exist across all platforms. This CL adds empty tests where a test was conditionally compiled out. This CL creates a single library libBionicTests that includes all of the tests found in bionic-unit-tests-static. Also fix a few missing include files in some test files. Tested by running and compiling the tests for every platform and verifying the same number of tests are on each platform. Change-Id: I9989d4bfebb0f9c409a0ce7e87169299eac605a2
* Wrap sprintf()/snprintf() macros to prevent expansion errors.Stephen Hines2013-10-111-0/+18
| | | | | | | | | | Previously, FORTIFY_SOURCE used single macros to define these standard functions for use with clang. This can cause conflicts with other macros used to call these functions, particularly when those macros expand the number of arguments to the function. This change wraps our macro definitions, so that expansion properly takes place for programmer arguments first. Change-Id: I55929b1fd2a643b9d14a17631c4bcab3b0b712cf
* FORTIFY_SOURCE: fortify read()Nick Kralevich2013-10-091-0/+10
| | | | Change-Id: Ic7de163fe121db13e00560adb257331bc709814d
* Revert "FORTIFY_SOURCE: fortify read()"Nick Kralevich2013-10-091-10/+0
| | | | | | | | This change reverts * fb3f956d075676c0438f2ee2bf3a5be659dfc04b. * 65c99de2cb7a569ea17ca35e2f8f1e033421864b Change-Id: Id5774eeede41130579115cf67a72ee914f2b47d5
* FORTIFY_SOURCE: fortify read()Nick Kralevich2013-10-091-0/+10
| | | | Change-Id: I3d7b4ec86d04efb865117ce7629a2e26917f3331
* Check memory size on FD_* functionsNick Kralevich2013-10-031-0/+14
| | | | | | | | Make sure the buffer we're dealing with has enough room. Might as well check for memory issues while we're here, even though I don't imagine they'll happen in practice. Change-Id: I0ae1f0f06aca9ceb91e58c70183bb14e275b92b5
* Fix 32-bit issues in tests, and add a trivial test for the FD_* macros.Elliott Hughes2013-10-021-1/+1
| | | | Change-Id: Ia3f21ce1f0ed9236527fe44d36ccb7de6bf63113
* FORTIFY_SOURCE: Add __FD_* checksNick Kralevich2013-10-021-0/+7
| | | | | | | | | | | Add FORTIFY_SOURCE checks for the following macros: * FD_CLR * FD_ISSET * FD_SET Bug: 11047121 Change-Id: I3c5952136aec9eff3288b91b1318677ff971525c
* Use alloc_size attribute on *alloc functionsNick Kralevich2013-10-021-0/+14
| | | | | | | | | | | | | | malloc and family were not declared with __attribute__((alloc_size)). This was (sometimes) preventing FORTIFY_SOURCE related functions from knowing the size of the buffer it's dealing with, inhibiting FORTIFY_SOURCE protections. Add __attribute__((alloc_size)) Information about the alloc_size attribute can be found at http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html Change-Id: Ia2f0a445f0170a7325f69259b5e7fb35a9f14921
* libc: fortify recvfrom()Nick Kralevich2013-09-241-0/+8
| | | | | | | | | Fortify calls to recv() and recvfrom(). We use __bos0 to match glibc's behavior, and because I haven't tested using __bos. Change-Id: Iad6ae96551a89af17a9c347b80cdefcf2020c505
* __memcpy_chk: Fix signed cmp of unsigned values.Christopher Ferris2013-09-201-0/+55
| | | | | | | | | | | | | | | I accidentally did a signed comparison of the size_t values passed in for three of the _chk functions. Changing them to unsigned compares. Add three new tests to verify this failure is fixed. Bug: 10691831 Merge from internal master. (cherry-picked from 883ef2499c2ff76605f73b1240f719ca6282e554) Change-Id: Id9a96b549435f5d9b61dc132cf1082e0e30889f5
* FORTIFY_SOURCE: introduce __strncpy_chk2Nick Kralevich2013-08-281-0/+60
| | | | | | | This change detects programs reading beyond the end of "src" when calling strncpy. Change-Id: Ie1b42de923385d62552b22c27b2d4713ab77ee03
* More FORTIFY_SOURCE functions under clangNick Kralevich2013-06-291-0/+48
| | | | | | | | * bzero * umask * strlcat Change-Id: I65065208e0b8b37e10f6a266d5305de8fa9e59fc
* Reorganize FORTIFY_SOURCE tests.Nick Kralevich2013-06-281-0/+611
Get rid of a lot of the duplication in the various FORTIFY_SOURCE tests. Instead, we build 4 separate static libraries, with 4 different compile time options, and link them into the final test binary. Change-Id: Idb0b7cccc8dd837adb037bf4ddfe8942ae138230