getdents, getdents64: fix potential out-of-bounds read issues

* file.c (sys_getdents): Check for invalid d_reclen.
Avoid reading from uninitialized memory.
(sys_getdents64): Likewise.
* tests/getdents.awk: New file.
* tests/getdents.test: New test.
* tests/Makefile.am (TESTS): Add it.
(EXTRA_DIST): Add getdents.awk.
4 files changed