summaryrefslogtreecommitdiff
path: root/tests/test_strncpy_overwrite_under.c (follow)
AgeCommit message (Collapse)Author
2024-10-10Fix a crash in strncpy/stpncpystrnjvoisin
``` Core was generated by `scripts/mod/modpost -M -m -o Module.symvers -n -T modules.order vmlinux.o'. Program terminated with signal SIGSEGV, Segmentation fault. warning: 17 src/string/strlen.c: No such file or directory (gdb) bt ``` > I think strncpy logic is broken: `__fh_size_t max_len_s = strlen(__s);` may try read past `size_t __n`. > Create a buf without any trailing `\0`, do `strncpy(dest, buf, sizeof(buf));`, it should work, since `strncpy` will stop at `sizeof buf` > but the current fority-headers implementation will do `strlen(buf)`, which will go boom when it is not terminated with \0 Reported-by: ncopa
2023-12-28Re-enable previously disabled overlap checksjvoisin
They were previously disabled in 80a83a5
2023-12-27Don't check for overlapping in strncpy/stpncpy for nowjvoisin
They check overlap across the whole range of the given length, but the given length is not what will actually be copied, rather it's the maximum length (if src is shorter, only length of src will be copied). This triggers false positives and traps where it shouldn't (e.g. in ICU tests). Reported-by: q66
2023-06-14Add tests for strncpy and handle overlapping buffers therejvoisin