summaryrefslogtreecommitdiff
path: root/test-str.c
AgeCommit message (Collapse)Author
2022-05-04test-str.c: fix gcc warnings with FORTIFY_SOURCE enabledAlexey Kodanev
* test_strncpy(). The test intentionally copies less than the total length of the string, so it looks like there is nothing we can do about it in the test other than explicitly ignoring the warnings. inlined from ‘test_strncpy’ at test-str.c:943:2: /usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ output may be truncated copying 1 byte from a string of length 8191 [-Werror=stringop-truncation] 106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ... * test_strcat(). The fix for the warning below is to avoid using overlapping buffers in src and dst. This is actually a requirement for both strcat() and strncpy(), so fix both functions. inlined from ‘test_strcat’ at test-str.c:1052:2: /usr/include/x86_64-linux-gnu/bits/string_fortified.h:128:10: error: ‘__builtin___strcat_chk’ accessing 4097 or more bytes at offsets 4096 and 0 may overlap 1 byte at offset 4096 [-Werror=restrict] 128 | return __builtin___strcat_chk (__dest, __src, __bos (__dest)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ... Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
2021-09-07Ignore a gcc issue in test-str.cPeter Jones
In 33db42def2ce, we switched a gcc bounds checking error in test-str.c to be a warning, due to it being obviously wrong and only occurring with some GCC optimization flags. For more details see the comment in test-str.c . It continues to be an issue, and the warning makes the -fanalyzer and similar tools even harder to read, so it's better to just turn it off. This is only in the test data, so if something really goes wrong we should see it in failures or in valgrind when running tests. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-22Make 'make test' work on gcc 4.8.5Peter Jones
2021-03-15Nerf an unnecessary string test on arm.Peter Jones
Steve McIntyre reports: <Sledge> yay, arm64 string test fail <Sledge> testing gnuefi_signed_strncmp <Sledge> test_strncmp:713:got 128, expected < 0 <Sledge> test_strncmp:713:Assertion `(gnuefi_signed_strncmp("sbat\314\234\014,", "sbat\314\034\014,", 9)) >= 0' failed. <Sledge> gnuefi_signed_strncmp failed <Sledge> looking at that code, this is a test to check how broken the gnuefi strncmp is, yes? <Sledge> and we're not actually using this implementation in shim AFAICS? That is a correct understanding, and as such this patch just removes that test from running on Arm platforms, where it is still too broken to even do this much. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-10Add more string test cases.Peter Jones
This adds test cases for the rest of our ASCII string functions. While doing so, it fixes two minor bugs: - strcasecmp() now handles utf8 correctly - strncpy() no longer does the stpncpy() behavior of clearing leftover buffer Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-10Test our strncmp vs known failing ones as wellPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-10Add some test cases, and make "make test" actually work.Peter Jones
Note the one test case I'm not 100% sure about. Someone let me know. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-25Add a tester for our string functions.Peter Jones
Note that building and running this test does not quite work yet /on this branch/. In order to do that, we need some cleanups and reorganizing that I don't want to push just yet, which can be found on https://github.com/rhboot/shim/tree/test-reorg Signed-off-by: Peter Jones <pjones@redhat.com>