commit 552cf2fc3165407cda3aa3146bd2b57c9beccb36 parent 906b7f6d576b10a8f20d858e379595c9a94cabfc Author: jvoisin <julien.voisin@dustri.org> Date: Tue, 11 Jul 2023 00:00:16 +0200 Add some dynamic tests for unistd.h Diffstat:
23 files changed, 192 insertions(+), 11 deletions(-)
diff --git a/tests/Makefile b/tests/Makefile @@ -38,19 +38,30 @@ TARGETS= \ test_stpncpy_overwrite_over \ test_stpncpy_overwrite_under \ test_stpncpy_static_write \ - test_confstr \ - test_getcwd \ + test_confstr_dynamic \ + test_confstr_static \ + test_getcwd_static \ + test_getcwd_dynamic \ test_poll \ test_ppoll \ - test_getdomainname \ - test_getgroups \ - test_gethostname \ - test_getlogin_r \ - test_pread \ - test_read \ - test_readlink \ - test_ttyname_r \ - test_write \ + test_getdomainname_static \ + test_getdomainname_dynamic \ + test_getgroups_static \ + test_getgroups_dynamic \ + test_gethostname_static \ + test_gethostname_dynamic \ + test_getlogin_r_static \ + test_getlogin_r_dynamic \ + test_pread_static \ + test_pread_dynamic \ + test_read_static \ + test_read_dynamic \ + test_readlink_static \ + test_readlink_dynamic \ + test_ttyname_r_static \ + test_ttyname_r_dynamic \ + test_write_static \ + test_write_dynamic \ test_fread_int_overflow \ test_fread_overwrite \ test_fwrite_int_overflow \ diff --git a/tests/test_confstr_dynamic.c b/tests/test_confstr_dynamic.c @@ -0,0 +1,16 @@ +#include "common.h" + +#include <unistd.h> + +int main(int argc, char** argv) { + char buffer[8] = {0}; + + confstr(_CS_PATH, buffer, 6); + + CHK_FAIL_START + confstr(_CS_PATH, buffer, argc); + CHK_FAIL_END + + puts(buffer); + return ret; +} diff --git a/tests/test_confstr.c b/tests/test_confstr_static.c diff --git a/tests/test_getcwd_dynamic.c b/tests/test_getcwd_dynamic.c @@ -0,0 +1,16 @@ +#include "common.h" + +#include <unistd.h> + +int main(int argc, char** argv) { + char buffer[8] = {0}; + + getcwd(buffer, 6); + + CHK_FAIL_START + getcwd(buffer, argc); + CHK_FAIL_END + + puts(buffer); + return ret; +} diff --git a/tests/test_getcwd.c b/tests/test_getcwd_static.c diff --git a/tests/test_getdomainname_dynamic.c b/tests/test_getdomainname_dynamic.c @@ -0,0 +1,18 @@ +#include "common.h" + +#define _GNU_SOURCE + +#include <unistd.h> + +int main(int argc, char** argv) { + char buffer[8] = {0}; + + getdomainname(buffer, 6); + + CHK_FAIL_START + getdomainname(buffer, argc); + CHK_FAIL_END + + puts(buffer); + return ret; +} diff --git a/tests/test_getdomainname.c b/tests/test_getdomainname_static.c diff --git a/tests/test_getgroups_dynamic.c b/tests/test_getgroups_dynamic.c @@ -0,0 +1,16 @@ +#include "common.h" + +#include <unistd.h> + +int main(int argc, char** argv) { + gid_t list[8] = {0}; + + getgroups(6, list); + + CHK_FAIL_START + getgroups(argc, list); + CHK_FAIL_END + + puts((const char*)list); + return ret; +} diff --git a/tests/test_getgroups.c b/tests/test_getgroups_static.c diff --git a/tests/test_gethostname_dynamic.c b/tests/test_gethostname_dynamic.c @@ -0,0 +1,16 @@ +#include "common.h" + +#include <unistd.h> + +int main(int argc, char** argv) { + char buffer[8] = {0}; + + gethostname(buffer, 6); + + CHK_FAIL_START + gethostname(buffer, argc); + CHK_FAIL_END + + puts(buffer); + return ret; +} diff --git a/tests/test_gethostname.c b/tests/test_gethostname_static.c diff --git a/tests/test_getlogin_r_dynamic.c b/tests/test_getlogin_r_dynamic.c @@ -0,0 +1,16 @@ +#include "common.h" + +#include <unistd.h> + +int main(int argc, char** argv) { + char buffer[8] = {0}; + + getlogin_r(buffer, 6); + + CHK_FAIL_START + getlogin_r(buffer, argc); + CHK_FAIL_END + + puts(buffer); + return ret; +} diff --git a/tests/test_getlogin_r.c b/tests/test_getlogin_r_static.c diff --git a/tests/test_pread_dynamic.c b/tests/test_pread_dynamic.c @@ -0,0 +1,14 @@ +#include "common.h" + +#include <unistd.h> + +int main(int argc, char** argv) { + char buffer[8] = {0}; + + CHK_FAIL_START + pread(0, buffer, argc, 0); + CHK_FAIL_END + + puts(buffer); + return ret; +} diff --git a/tests/test_pread.c b/tests/test_pread_static.c diff --git a/tests/test_read_dynamic.c b/tests/test_read_dynamic.c @@ -0,0 +1,14 @@ +#include "common.h" + +#include <unistd.h> + +int main(int argc, char** argv) { + char buffer[8] = {0}; + + CHK_FAIL_START + read(0, buffer, argc); + CHK_FAIL_END + + puts(buffer); + return ret; +} diff --git a/tests/test_read.c b/tests/test_read_static.c diff --git a/tests/test_readlink_dynamic.c b/tests/test_readlink_dynamic.c @@ -0,0 +1,16 @@ +#include "common.h" + +#include <unistd.h> + +int main(int argc, char** argv) { + char buffer[8] = {0}; + + readlink("", buffer, 6); + + CHK_FAIL_START + readlink("", buffer, argc); + CHK_FAIL_END + + puts(buffer); + return ret; +} diff --git a/tests/test_readlink.c b/tests/test_readlink_static.c diff --git a/tests/test_ttyname_r_dynamic.c b/tests/test_ttyname_r_dynamic.c @@ -0,0 +1,14 @@ +#include "common.h" + +#include <unistd.h> + +int main(int argc, char** argv) { + char buffer[8] = {0}; + + CHK_FAIL_START + ttyname_r(0, buffer, argc); + CHK_FAIL_END + + puts(buffer); + return ret; +} diff --git a/tests/test_ttyname_r.c b/tests/test_ttyname_r_static.c diff --git a/tests/test_write_dynamic.c b/tests/test_write_dynamic.c @@ -0,0 +1,14 @@ +#include "common.h" + +#include <unistd.h> + +int main(int argc, char** argv) { + char buffer[8] = {0}; + + CHK_FAIL_START + write(0, buffer, argc); + CHK_FAIL_END + + puts(buffer); + return ret; +} diff --git a/tests/test_write.c b/tests/test_write_static.c