From 710bab74e01b0a487189c35e71df0719768ab9bc Mon Sep 17 00:00:00 2001 From: gaorui Date: Fri, 23 Dec 2022 17:35:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0fuzz=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ib07c89fe4fb840f2be4eec40a379a8f13e5ef2b6 Signed-off-by: gaorui --- testsuites/BUILD.gn | 1 + testsuites/fuzz/BUILD.gn | 86 ++++++++++++ testsuites/fuzz/adjtime_fuzzer.cpp | 45 +++++++ testsuites/fuzz/clone_fuzzer.cpp | 61 +++++++++ testsuites/fuzz/epoll_create_fuzzer.cpp | 42 ++++++ testsuites/fuzz/epoll_ctl_fuzzer.cpp | 48 +++++++ testsuites/fuzz/epoll_wait_fuzzer.cpp | 48 +++++++ testsuites/fuzz/fesetenv_fuzzer.cpp | 43 ++++++ testsuites/fuzz/getrlimit_fuzzer.cpp | 45 +++++++ testsuites/fuzz/main.cpp | 127 ++++++++++++++++++ testsuites/fuzz/mlock_fuzzer.cpp | 44 ++++++ testsuites/fuzz/mlockall_fuzzer.cpp | 42 ++++++ ..._spawn_file_actions_addchdir_np_fuzzer.cpp | 52 +++++++ ...osix_spawn_file_actions_adddup2_fuzzer.cpp | 53 ++++++++ ...spawn_file_actions_addfchdir_np_fuzzer.cpp | 52 +++++++ ...osix_spawn_file_actions_addopen_fuzzer.cpp | 55 ++++++++ ...osix_spawn_file_actions_destroy_fuzzer.cpp | 52 +++++++ .../posix_spawn_file_actions_init_fuzzer.cpp | 51 +++++++ testsuites/fuzz/posix_spawn_fuzzer.cpp | 43 ++++++ .../fuzz/posix_spawnattr_destroy_fuzzer.cpp | 45 +++++++ .../fuzz/posix_spawnattr_getflags_fuzzer.cpp | 46 +++++++ .../fuzz/posix_spawnattr_getpgroup_fuzzer.cpp | 46 +++++++ .../posix_spawnattr_getschedparam_fuzzer.cpp | 49 +++++++ .../posix_spawnattr_getschedpolicy_fuzzer.cpp | 46 +++++++ .../posix_spawnattr_getsigdefault_fuzzer.cpp | 47 +++++++ .../posix_spawnattr_getsigmask_fuzzer.cpp | 47 +++++++ .../fuzz/posix_spawnattr_init_fuzzer.cpp | 45 +++++++ .../fuzz/posix_spawnattr_setflags_fuzzer.cpp | 46 +++++++ .../fuzz/posix_spawnattr_setpgroup_fuzzer.cpp | 46 +++++++ .../posix_spawnattr_setschedparam_fuzzer.cpp | 49 +++++++ .../posix_spawnattr_setschedpolicy_fuzzer.cpp | 47 +++++++ .../posix_spawnattr_setsigdefault_fuzzer.cpp | 47 +++++++ .../posix_spawnattr_setsigmask_fuzzer.cpp | 47 +++++++ testsuites/fuzz/posix_spawnp_fuzzer.cpp | 45 +++++++ .../fuzz/pthread_mutex_consistent_fuzzer.cpp | 45 +++++++ .../pthread_mutex_getprioceiling_fuzzer.cpp | 49 +++++++ .../pthread_mutexattr_setprotocol_fuzzer.cpp | 46 +++++++ .../pthread_mutexattr_setrobust_fuzzer.cpp | 46 +++++++ .../fuzz/pthread_mutexattr_settype_fuzzer.cpp | 46 +++++++ .../fuzz/pthread_setconcurrency_fuzzer.cpp | 42 ++++++ testsuites/fuzz/readlink_fuzzer.cpp | 44 ++++++ testsuites/fuzz/readlinkat_fuzzer.cpp | 45 +++++++ testsuites/fuzz/sem_open_fuzzer.cpp | 43 ++++++ testsuites/fuzz/setns_fuzzer.cpp | 43 ++++++ testsuites/fuzz/syslog_fuzzer.cpp | 43 ++++++ testsuites/fuzz/system_fuzzer.cpp | 43 ++++++ testsuites/fuzz/times_fuzzer.cpp | 45 +++++++ testsuites/fuzz/unshare_fuzzer.cpp | 42 ++++++ 48 files changed, 2310 insertions(+) create mode 100644 testsuites/fuzz/BUILD.gn create mode 100644 testsuites/fuzz/adjtime_fuzzer.cpp create mode 100644 testsuites/fuzz/clone_fuzzer.cpp create mode 100644 testsuites/fuzz/epoll_create_fuzzer.cpp create mode 100644 testsuites/fuzz/epoll_ctl_fuzzer.cpp create mode 100644 testsuites/fuzz/epoll_wait_fuzzer.cpp create mode 100644 testsuites/fuzz/fesetenv_fuzzer.cpp create mode 100644 testsuites/fuzz/getrlimit_fuzzer.cpp create mode 100644 testsuites/fuzz/main.cpp create mode 100644 testsuites/fuzz/mlock_fuzzer.cpp create mode 100644 testsuites/fuzz/mlockall_fuzzer.cpp create mode 100644 testsuites/fuzz/posix_spawn_file_actions_addchdir_np_fuzzer.cpp create mode 100644 testsuites/fuzz/posix_spawn_file_actions_adddup2_fuzzer.cpp create mode 100644 testsuites/fuzz/posix_spawn_file_actions_addfchdir_np_fuzzer.cpp create mode 100644 testsuites/fuzz/posix_spawn_file_actions_addopen_fuzzer.cpp create mode 100644 testsuites/fuzz/posix_spawn_file_actions_destroy_fuzzer.cpp create mode 100644 testsuites/fuzz/posix_spawn_file_actions_init_fuzzer.cpp create mode 100644 testsuites/fuzz/posix_spawn_fuzzer.cpp create mode 100644 testsuites/fuzz/posix_spawnattr_destroy_fuzzer.cpp create mode 100644 testsuites/fuzz/posix_spawnattr_getflags_fuzzer.cpp create mode 100644 testsuites/fuzz/posix_spawnattr_getpgroup_fuzzer.cpp create mode 100644 testsuites/fuzz/posix_spawnattr_getschedparam_fuzzer.cpp create mode 100644 testsuites/fuzz/posix_spawnattr_getschedpolicy_fuzzer.cpp create mode 100644 testsuites/fuzz/posix_spawnattr_getsigdefault_fuzzer.cpp create mode 100644 testsuites/fuzz/posix_spawnattr_getsigmask_fuzzer.cpp create mode 100644 testsuites/fuzz/posix_spawnattr_init_fuzzer.cpp create mode 100644 testsuites/fuzz/posix_spawnattr_setflags_fuzzer.cpp create mode 100644 testsuites/fuzz/posix_spawnattr_setpgroup_fuzzer.cpp create mode 100644 testsuites/fuzz/posix_spawnattr_setschedparam_fuzzer.cpp create mode 100644 testsuites/fuzz/posix_spawnattr_setschedpolicy_fuzzer.cpp create mode 100644 testsuites/fuzz/posix_spawnattr_setsigdefault_fuzzer.cpp create mode 100644 testsuites/fuzz/posix_spawnattr_setsigmask_fuzzer.cpp create mode 100644 testsuites/fuzz/posix_spawnp_fuzzer.cpp create mode 100644 testsuites/fuzz/pthread_mutex_consistent_fuzzer.cpp create mode 100644 testsuites/fuzz/pthread_mutex_getprioceiling_fuzzer.cpp create mode 100644 testsuites/fuzz/pthread_mutexattr_setprotocol_fuzzer.cpp create mode 100644 testsuites/fuzz/pthread_mutexattr_setrobust_fuzzer.cpp create mode 100644 testsuites/fuzz/pthread_mutexattr_settype_fuzzer.cpp create mode 100644 testsuites/fuzz/pthread_setconcurrency_fuzzer.cpp create mode 100644 testsuites/fuzz/readlink_fuzzer.cpp create mode 100644 testsuites/fuzz/readlinkat_fuzzer.cpp create mode 100644 testsuites/fuzz/sem_open_fuzzer.cpp create mode 100644 testsuites/fuzz/setns_fuzzer.cpp create mode 100644 testsuites/fuzz/syslog_fuzzer.cpp create mode 100644 testsuites/fuzz/system_fuzzer.cpp create mode 100644 testsuites/fuzz/times_fuzzer.cpp create mode 100644 testsuites/fuzz/unshare_fuzzer.cpp diff --git a/testsuites/BUILD.gn b/testsuites/BUILD.gn index c09cb41c..d6e02339 100644 --- a/testsuites/BUILD.gn +++ b/testsuites/BUILD.gn @@ -37,5 +37,6 @@ group("testsuites") { deps = [] if (liteos_kernel_unittest) { deps += [ "unittest" ] + #deps += [ "//kernel/liteos_a/testsuites/fuzz:fuzztest" ] } } diff --git a/testsuites/fuzz/BUILD.gn b/testsuites/fuzz/BUILD.gn new file mode 100644 index 00000000..da2b4b97 --- /dev/null +++ b/testsuites/fuzz/BUILD.gn @@ -0,0 +1,86 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import("//build/lite/config/test.gni") + +fuzztest("FuzzDemoTest") { + output_extension = "bin" + sources = [ + "adjtime_fuzzer.cpp", + "clone_fuzzer.cpp", + "epoll_create_fuzzer.cpp", + "epoll_ctl_fuzzer.cpp", + "epoll_wait_fuzzer.cpp", + "fesetenv_fuzzer.cpp", + "getrlimit_fuzzer.cpp", + "main.cpp", + "mlock_fuzzer.cpp", + "mlockall_fuzzer.cpp", + "posix_spawn_file_actions_addchdir_np_fuzzer.cpp", + "posix_spawn_file_actions_adddup2_fuzzer.cpp", + "posix_spawn_file_actions_addfchdir_np_fuzzer.cpp", + "posix_spawn_file_actions_addopen_fuzzer.cpp", + "posix_spawn_file_actions_destroy_fuzzer.cpp", + "posix_spawn_file_actions_init_fuzzer.cpp", + "posix_spawn_fuzzer.cpp", + "posix_spawnattr_destroy_fuzzer.cpp", + "posix_spawnattr_getflags_fuzzer.cpp", + "posix_spawnattr_getpgroup_fuzzer.cpp", + "posix_spawnattr_getschedparam_fuzzer.cpp", + "posix_spawnattr_getschedpolicy_fuzzer.cpp", + "posix_spawnattr_getsigdefault_fuzzer.cpp", + "posix_spawnattr_getsigmask_fuzzer.cpp", + "posix_spawnattr_init_fuzzer.cpp", + "posix_spawnattr_setflags_fuzzer.cpp", + "posix_spawnattr_setpgroup_fuzzer.cpp", + "posix_spawnattr_setschedparam_fuzzer.cpp", + "posix_spawnattr_setschedpolicy_fuzzer.cpp", + "posix_spawnattr_setsigdefault_fuzzer.cpp", + "posix_spawnattr_setsigmask_fuzzer.cpp", + "posix_spawnp_fuzzer.cpp", + "pthread_mutex_consistent_fuzzer.cpp", + "pthread_mutex_getprioceiling_fuzzer.cpp", + "pthread_mutexattr_setprotocol_fuzzer.cpp", + "pthread_mutexattr_setrobust_fuzzer.cpp", + "pthread_mutexattr_settype_fuzzer.cpp", + "pthread_setconcurrency_fuzzer.cpp", + "readlink_fuzzer.cpp", + "readlinkat_fuzzer.cpp", + "sem_open_fuzzer.cpp", + "setns_fuzzer.cpp", + "syslog_fuzzer.cpp", + "system_fuzzer.cpp", + "times_fuzzer.cpp", + "unshare_fuzzer.cpp", + ] + include_dirs = [] + deps = [] +} +group("fuzztest") { + deps = [ ":FuzzDemoTest" ] +} diff --git a/testsuites/fuzz/adjtime_fuzzer.cpp b/testsuites/fuzz/adjtime_fuzzer.cpp new file mode 100644 index 00000000..e98899ed --- /dev/null +++ b/testsuites/fuzz/adjtime_fuzzer.cpp @@ -0,0 +1,45 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_adjtime(void) +{ + struct timeval fa; + printf("start----adjtime\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_adjtime"), 0) + { + char *delta = DT_SetGetFixBlob(&g_Element[0], sizeof(struct timeval), sizeof(struct timeval), (char *)&fa); + char *olddelta = DT_SetGetFixBlob(&g_Element[1], sizeof(struct timeval), sizeof(struct timeval), (char *)&fa); + adjtime((struct timeval *)delta, (struct timeval *)olddelta); + } + DT_FUZZ_END() + printf("end----adjtime\n"); +} diff --git a/testsuites/fuzz/clone_fuzzer.cpp b/testsuites/fuzz/clone_fuzzer.cpp new file mode 100644 index 00000000..86e3e6bc --- /dev/null +++ b/testsuites/fuzz/clone_fuzzer.cpp @@ -0,0 +1,61 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include +#include +#include +#include +#include +#include +#include + +static int STACK_SIZE = 1024 * 1024; + +static int childFunc(void *) +{ + return 0; +} + +void test_clone(void) +{ + printf("start----test_clone\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_clone"), 0) + { + char *stack; + char *stackTop; + s32 number = *(s32 *)DT_SetGetS32(&g_Element[0], 0x123456); + stack = (char *)mmap(NULL, STACK_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0); + stackTop = stack + STACK_SIZE; + pid_t pid = clone(childFunc, stackTop, number, NULL); + waitpid(pid, NULL, WUNTRACED); + } + DT_FUZZ_END() + printf("end----test_clone\n"); +} diff --git a/testsuites/fuzz/epoll_create_fuzzer.cpp b/testsuites/fuzz/epoll_create_fuzzer.cpp new file mode 100644 index 00000000..ed152d10 --- /dev/null +++ b/testsuites/fuzz/epoll_create_fuzzer.cpp @@ -0,0 +1,42 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include + +void test_epoll_create(void) +{ + printf("start----test_epoll_create\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_epoll_create"), 0) + { + s32 number = *(s32 *)DT_SetGetS32(&g_Element[0], 0x123456); + epoll_create(number); + } + DT_FUZZ_END() + printf("end----test_epoll_create\n"); +} diff --git a/testsuites/fuzz/epoll_ctl_fuzzer.cpp b/testsuites/fuzz/epoll_ctl_fuzzer.cpp new file mode 100644 index 00000000..17e20929 --- /dev/null +++ b/testsuites/fuzz/epoll_ctl_fuzzer.cpp @@ -0,0 +1,48 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_epoll_ctl(void) +{ + struct epoll_event fa; + printf("start----test_epoll_ctl\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_epoll_ctl"), 0) + { + s32 number0 = *(s32 *)DT_SetGetS32(&g_Element[0], 0x123456); + s32 number1 = *(s32 *)DT_SetGetS32(&g_Element[1], 0x123456); + s32 number2 = *(s32 *)DT_SetGetS32(&g_Element[2], 0x123456); + char *datainput = DT_SetGetFixBlob(&g_Element[3], sizeof(struct epoll_event), sizeof(struct epoll_event), + (char *)&fa); + epoll_ctl(number0, number1, number2, (struct epoll_event *)datainput); + } + DT_FUZZ_END() + printf("end----test_epoll_ctl\n"); +} diff --git a/testsuites/fuzz/epoll_wait_fuzzer.cpp b/testsuites/fuzz/epoll_wait_fuzzer.cpp new file mode 100644 index 00000000..1633f776 --- /dev/null +++ b/testsuites/fuzz/epoll_wait_fuzzer.cpp @@ -0,0 +1,48 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_epoll_wait(void) +{ + struct epoll_event fa; + printf("start----test_epoll_wait\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_epoll_wait"), 0) + { + s32 number0 = *(s32 *)DT_SetGetS32(&g_Element[0], 0x123456); + s32 number1 = *(s32 *)DT_SetGetS32(&g_Element[1], 0x123456); + s32 number2 = *(s32 *)DT_SetGetS32(&g_Element[2], 0x123456); + char *datainput = DT_SetGetFixBlob(&g_Element[3], sizeof(struct epoll_event), sizeof(struct epoll_event), + (char *)&fa); + epoll_wait(number0, (struct epoll_event *)datainput, number1, number2); + } + DT_FUZZ_END() + printf("end----test_epoll_wait\n"); +} diff --git a/testsuites/fuzz/fesetenv_fuzzer.cpp b/testsuites/fuzz/fesetenv_fuzzer.cpp new file mode 100644 index 00000000..462714ee --- /dev/null +++ b/testsuites/fuzz/fesetenv_fuzzer.cpp @@ -0,0 +1,43 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include + +void test_fesetenv(void) +{ + fenv_t fa; + printf("start----fesetenv\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_fesetenv"), 0) + { + char *envp = DT_SetGetFixBlob(&g_Element[0], sizeof(fenv_t), sizeof(fenv_t), (char *)&fa); + fesetenv((fenv_t *)envp); + } + DT_FUZZ_END() + printf("end----fesetenv\n"); +} diff --git a/testsuites/fuzz/getrlimit_fuzzer.cpp b/testsuites/fuzz/getrlimit_fuzzer.cpp new file mode 100644 index 00000000..a270a888 --- /dev/null +++ b/testsuites/fuzz/getrlimit_fuzzer.cpp @@ -0,0 +1,45 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_getrlimit(void) +{ + struct rlimit fa; + printf("start----getrlimit\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_getrlimit"), 0) + { + s32 resource = *(s32 *)DT_SetGetS32(&g_Element[0], 0x123456); + char *datainput = DT_SetGetFixBlob(&g_Element[1], sizeof(struct rlimit), sizeof(struct rlimit), (char *)&fa); + getrlimit(resource, (struct rlimit *)datainput); + } + DT_FUZZ_END() + printf("end----getrlimit\n"); +} diff --git a/testsuites/fuzz/main.cpp b/testsuites/fuzz/main.cpp new file mode 100644 index 00000000..7caa3e36 --- /dev/null +++ b/testsuites/fuzz/main.cpp @@ -0,0 +1,127 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include + +extern void test_posix_spawn_file_actions_addchdir_np(void); +extern void test_posix_spawn_file_actions_adddup2(void); +extern void test_posix_spawn_file_actions_addfchdir_np(void); +extern void test_posix_spawn_file_actions_addopen(void); +extern void test_posix_spawn_file_actions_destroy(void); +extern void test_posix_spawn_file_actions_init(void); +extern void test_posix_spawn(void); +extern void test_posix_spawnattr_destroy(void); +extern void test_posix_spawnattr_getflags(void); +extern void test_posix_spawnattr_getpgroup(void); +extern void test_posix_spawnattr_getschedparam(void); +extern void test_posix_spawnattr_getschedpolicy(void); +extern void test_posix_spawnattr_getsigdefault(void); +extern void test_posix_spawnattr_getsigmask(void); +extern void test_posix_spawnattr_init(void); +extern void test_posix_spawnattr_setflags(void); +extern void test_posix_spawnattr_setpgroup(void); +extern void test_posix_spawnattr_setschedparam(void); +extern void test_posix_spawnattr_setschedpolicy(void); +extern void test_posix_spawnattr_setsigdefault(void); +extern void test_posix_spawnattr_setsigmask(void); +extern void test_posix_spawnp(void); +extern void test_adjtime(void); +extern void test_fesetenv(void); +extern void test_getrlimit(void); +extern void test_readlink(void); +extern void test_readlinkatat(void); +extern void test_syslog(void); +extern void test_system(void); +extern void test_times(void); +extern void test_clone(void); +extern void test_epoll_create(void); +extern void test_epoll_ctl(void); +extern void test_epoll_wait(void); +extern void test_mlock(void); +extern void test_mlockall(void); +extern void test_pthread_mutex_consistent(void); +extern void test_pthread_mutex_getprioceiling(void); +extern void test_pthread_mutexattr_setprotocol(void); +extern void test_pthread_mutexattr_setrobust(void); +extern void test_pthread_mutexattr_settype(void); +extern void test_pthread_setconcurrency(void); +extern void test_setns(void); +extern void test_unshare(void); +extern void test_sem_open(void); + +int main() +{ + DT_Set_Report_Path("/storage/"); + test_posix_spawn_file_actions_addchdir_np(); + test_posix_spawn_file_actions_addopen(); + test_posix_spawn_file_actions_adddup2(); + test_posix_spawn_file_actions_addfchdir_np(); + test_posix_spawn_file_actions_destroy(); + test_posix_spawn_file_actions_init(); + test_posix_spawnattr_destroy(); + test_posix_spawnattr_getflags(); + test_posix_spawnattr_getpgroup(); + test_posix_spawnattr_getschedparam(); + test_posix_spawnattr_getschedpolicy(); + test_posix_spawnattr_getsigdefault(); + test_posix_spawnattr_getsigmask(); + test_posix_spawnattr_init(); + test_posix_spawnattr_setflags(); + test_posix_spawnattr_setpgroup(); + test_posix_spawnattr_setschedparam(); + test_posix_spawnattr_setschedpolicy(); + test_posix_spawnattr_setsigdefault(); + test_posix_spawnattr_setsigmask(); + test_posix_spawn(); + test_posix_spawnp(); + test_syslog(); + test_system(); + test_mlock(); + test_mlockall(); + test_adjtime(); + test_fesetenv(); + test_getrlimit(); + test_readlink(); + test_readlinkatat(); + test_times(); + test_clone(); + test_epoll_create(); + test_epoll_ctl(); + test_epoll_wait(); + test_pthread_mutex_consistent(); + test_pthread_mutex_getprioceiling(); + test_pthread_mutexattr_setprotocol(); + test_pthread_mutexattr_setrobust(); + test_pthread_mutexattr_settype(); + test_pthread_setconcurrency(); + test_setns(); + test_sem_open(); + test_unshare(); + + return 0; +} diff --git a/testsuites/fuzz/mlock_fuzzer.cpp b/testsuites/fuzz/mlock_fuzzer.cpp new file mode 100644 index 00000000..2057e323 --- /dev/null +++ b/testsuites/fuzz/mlock_fuzzer.cpp @@ -0,0 +1,44 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include + +void test_mlock(void) +{ + int lockSize = 4096 + 1; + printf("start----test_mlock\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_mlock"), 0) + { + char *p = DT_SetGetString(&g_Element[0], 6, 10000, "123456"); + mlock(p, lockSize); + munlock(p, lockSize); + } + DT_FUZZ_END() + printf("end----test_mlock\n"); +} diff --git a/testsuites/fuzz/mlockall_fuzzer.cpp b/testsuites/fuzz/mlockall_fuzzer.cpp new file mode 100644 index 00000000..990bb2b0 --- /dev/null +++ b/testsuites/fuzz/mlockall_fuzzer.cpp @@ -0,0 +1,42 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include + +void test_mlockall(void) +{ + printf("start----test_mlockall\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_mlockall"), 0) + { + s32 number = *(s32 *)DT_SetGetS32(&g_Element[0], 0x123456); + mlockall(number); + } + DT_FUZZ_END() + printf("end----test_mlockall\n"); +} diff --git a/testsuites/fuzz/posix_spawn_file_actions_addchdir_np_fuzzer.cpp b/testsuites/fuzz/posix_spawn_file_actions_addchdir_np_fuzzer.cpp new file mode 100644 index 00000000..afde72a1 --- /dev/null +++ b/testsuites/fuzz/posix_spawn_file_actions_addchdir_np_fuzzer.cpp @@ -0,0 +1,52 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_posix_spawn_file_actions_addchdir_np(void) +{ + posix_spawn_file_actions_t fa; + printf("start ---- test_posix_spawn_file_actions_addchdir_np\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_posix_spawn_file_actions_addchdir_np"), 0) + { + fa.__pad0[0] = *(s32 *)DT_SetGetS32(&g_Element[0], 0x123456); + fa.__pad0[1] = *(s32 *)DT_SetGetS32(&g_Element[1], 0x123456); + fa.__pad0[2] = *(s32 *)DT_SetGetS32(&g_Element[2], 0x123456); + for (int i = 0; i < 16; i++) { + fa.__pad[i] = *(s32 *)DT_SetGetS32(&g_Element[i+3], 0x123456); + } + char *action = DT_SetGetBlob(&g_Element[18], 6, 10000, "123456"); + fa.__actions=(void *)action; + char *path = DT_SetGetString(&g_Element[19], 6, 10000, "123456"); + posix_spawn_file_actions_addchdir_np(&fa, path); + } + DT_FUZZ_END(); + printf("end --- test_posix_spawn_file_actions_addchdir_np\n"); +} diff --git a/testsuites/fuzz/posix_spawn_file_actions_adddup2_fuzzer.cpp b/testsuites/fuzz/posix_spawn_file_actions_adddup2_fuzzer.cpp new file mode 100644 index 00000000..6d88b327 --- /dev/null +++ b/testsuites/fuzz/posix_spawn_file_actions_adddup2_fuzzer.cpp @@ -0,0 +1,53 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include +#include "gtest/gtest.h" + +void test_posix_spawn_file_actions_adddup2(void) +{ + posix_spawn_file_actions_t fa; + printf("start ---- test_posix_spawn_file_actions_adddup2\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_posix_spawn_file_actions_adddup2"), 0) + { + fa.__pad0[0] = *(s32 *)DT_SetGetS32(&g_Element[0], 0x123456); + fa.__pad0[1] = *(s32 *)DT_SetGetS32(&g_Element[1], 0x123456); + fa.__pad0[2] = *(s32 *)DT_SetGetS32(&g_Element[2], 0x123456); + for (int i = 0; i < 16; i++) { + fa.__pad[i] = *(s32 *)DT_SetGetS32(&g_Element[i+3], 0x123456); + } + char *action = DT_SetGetBlob(&g_Element[18], 6, 10000, "123456"); + fa.__actions=(void *)action; + s32 tmpfd = *(s32 *)DT_SetGetS32(&g_Element[19], 0x123456); + posix_spawn_file_actions_adddup2(&fa, STDOUT_FILENO, tmpfd); + } + DT_FUZZ_END(); + printf("end --- test_posix_spawn_file_actions_adddup2\n"); +} diff --git a/testsuites/fuzz/posix_spawn_file_actions_addfchdir_np_fuzzer.cpp b/testsuites/fuzz/posix_spawn_file_actions_addfchdir_np_fuzzer.cpp new file mode 100644 index 00000000..20a7ed35 --- /dev/null +++ b/testsuites/fuzz/posix_spawn_file_actions_addfchdir_np_fuzzer.cpp @@ -0,0 +1,52 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_posix_spawn_file_actions_addfchdir_np(void) +{ + posix_spawn_file_actions_t fa; + printf("start ---- test_posix_spawn_file_actions_addfchdir_np\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_posix_spawn_file_actions_addfchdir_np"), 0) + { + fa.__pad0[0] = *(s32 *)DT_SetGetS32(&g_Element[0], 0x123456); + fa.__pad0[1] = *(s32 *)DT_SetGetS32(&g_Element[1], 0x123456); + fa.__pad0[2] = *(s32 *)DT_SetGetS32(&g_Element[2], 0x123456); + for (int i = 0; i < 16; i++) { + fa.__pad[i] = *(s32 *)DT_SetGetS32(&g_Element[i+3], 0x123456); + } + char *action = DT_SetGetBlob(&g_Element[18], 6, 10000, "123456"); + fa.__actions=(void *)action; + s32 tmpfd = *(s32 *)DT_SetGetS32(&g_Element[19], 0x123456); + posix_spawn_file_actions_addfchdir_np(&fa, tmpfd); + } + DT_FUZZ_END(); + printf("end --- test_posix_spawn_file_actions_addfchdir_np\n"); +} diff --git a/testsuites/fuzz/posix_spawn_file_actions_addopen_fuzzer.cpp b/testsuites/fuzz/posix_spawn_file_actions_addopen_fuzzer.cpp new file mode 100644 index 00000000..26e90b57 --- /dev/null +++ b/testsuites/fuzz/posix_spawn_file_actions_addopen_fuzzer.cpp @@ -0,0 +1,55 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_posix_spawn_file_actions_addopen(void) +{ + posix_spawn_file_actions_t fa; + printf("start ---- test_posix_spawn_file_actions_addopen\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_posix_spawn_file_actions_addopen"), 0) + { + fa.__pad0[0] = *(s32 *)DT_SetGetS32(&g_Element[0], 0x123456); + fa.__pad0[1] = *(s32 *)DT_SetGetS32(&g_Element[1], 0x123456); + fa.__pad0[2] = *(s32 *)DT_SetGetS32(&g_Element[2], 0x123456); + for (int i = 0; i < 16; i++) { + fa.__pad[i] = *(s32 *)DT_SetGetS32(&g_Element[i+3], 0x123456); + } + char *action = DT_SetGetBlob(&g_Element[18], 6, 10000, "123456"); + fa.__actions=(void *)action; + s32 tmpfd = *(s32 *)DT_SetGetS32(&g_Element[19], 0x123456); + char *path = DT_SetGetBlob(&g_Element[20], 6, 10000, "123456"); + s32 flag = *(s32 *)DT_SetGetS32(&g_Element[21], 0x123456); + posix_spawn_file_actions_addopen(&fa, tmpfd, path, flag, 0); + posix_spawn_file_actions_addclose(&fa, tmpfd); + } + DT_FUZZ_END(); + printf("end --- test_posix_spawn_file_actions_addopen\n"); +} diff --git a/testsuites/fuzz/posix_spawn_file_actions_destroy_fuzzer.cpp b/testsuites/fuzz/posix_spawn_file_actions_destroy_fuzzer.cpp new file mode 100644 index 00000000..6d0be082 --- /dev/null +++ b/testsuites/fuzz/posix_spawn_file_actions_destroy_fuzzer.cpp @@ -0,0 +1,52 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_posix_spawn_file_actions_destroy(void) +{ + posix_spawn_file_actions_t fa; + printf("start ---- test_posix_spawn_file_actions_destroy\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_posix_spawn_file_actions_destroy"), 0) + { + fa.__pad0[0] = *(s32 *)DT_SetGetS32(&g_Element[0], 0x123456); + fa.__pad0[1] = *(s32 *)DT_SetGetS32(&g_Element[1], 0x123456); + fa.__pad0[2] = *(s32 *)DT_SetGetS32(&g_Element[2], 0x123456); + for (int i = 0; i < 16; i++) { + fa.__pad[i] = *(s32 *)DT_SetGetS32(&g_Element[i+3], 0x123456); + } + char *action = DT_SetGetBlob(&g_Element[18], 6, 10000, "123456"); + fa.__actions=(void *)action; + posix_spawn_file_actions_init(&fa); + posix_spawn_file_actions_destroy(&fa); + } + DT_FUZZ_END(); + printf("end --- test_posix_spawn_file_actions_destroy\n"); +} diff --git a/testsuites/fuzz/posix_spawn_file_actions_init_fuzzer.cpp b/testsuites/fuzz/posix_spawn_file_actions_init_fuzzer.cpp new file mode 100644 index 00000000..60fdb294 --- /dev/null +++ b/testsuites/fuzz/posix_spawn_file_actions_init_fuzzer.cpp @@ -0,0 +1,51 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_posix_spawn_file_actions_init(void) +{ + posix_spawn_file_actions_t fa; + printf("start ---- test_posix_spawn_file_actions_init\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_posix_spawn_file_actions_init"), 0) + { + fa.__pad0[0] = *(s32 *)DT_SetGetS32(&g_Element[0], 0x123456); + fa.__pad0[1] = *(s32 *)DT_SetGetS32(&g_Element[1], 0x123456); + fa.__pad0[2] = *(s32 *)DT_SetGetS32(&g_Element[2], 0x123456); + for (int i = 0; i < 16; i++) { + fa.__pad[i] = *(s32 *)DT_SetGetS32(&g_Element[i+3], 0x123456); + } + char *action = DT_SetGetBlob(&g_Element[18], 6, 10000, "123456"); + fa.__actions=(void *)action; + posix_spawn_file_actions_init(&fa); + } + DT_FUZZ_END(); + printf("end --- test_posix_spawn_file_actions_init\n"); +} diff --git a/testsuites/fuzz/posix_spawn_fuzzer.cpp b/testsuites/fuzz/posix_spawn_fuzzer.cpp new file mode 100644 index 00000000..cc01cd06 --- /dev/null +++ b/testsuites/fuzz/posix_spawn_fuzzer.cpp @@ -0,0 +1,43 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include + +void test_posix_spawn(void) +{ + printf("start ---- test_posix_spawn\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_posix_spawn"), 0) + { + s32 pid = *(s32 *)DT_SetGetS32(&g_Element[0], 0x123456); + char *argv[] = {"tftp", nullptr}; + posix_spawn(&pid, "/bin/tftp", nullptr, nullptr, argv, nullptr); + } + DT_FUZZ_END(); + printf("end --- test_posix_spawn\n"); +} diff --git a/testsuites/fuzz/posix_spawnattr_destroy_fuzzer.cpp b/testsuites/fuzz/posix_spawnattr_destroy_fuzzer.cpp new file mode 100644 index 00000000..b185b2bd --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_destroy_fuzzer.cpp @@ -0,0 +1,45 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_posix_spawnattr_destroy(void) +{ + posix_spawnattr_t attr; + printf("start ---- test_posix_spawnattr_destroy\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_posix_spawnattr_destroy"), 0) + { + char *datainput = DT_SetGetFixBlob(&g_Element[0], sizeof(posix_spawnattr_t), sizeof(posix_spawnattr_t), + (char *)&attr); + posix_spawnattr_destroy((posix_spawnattr_t *)datainput); + } + DT_FUZZ_END(); + printf("end --- test_posix_spawnattr_destroy\n"); +} diff --git a/testsuites/fuzz/posix_spawnattr_getflags_fuzzer.cpp b/testsuites/fuzz/posix_spawnattr_getflags_fuzzer.cpp new file mode 100644 index 00000000..46fa151c --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_getflags_fuzzer.cpp @@ -0,0 +1,46 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_posix_spawnattr_getflags(void) +{ + posix_spawnattr_t attr; + printf("start ---- test_posix_spawnattr_getflags\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_posix_spawnattr_getflags"), 0) + { + char *datainput = DT_SetGetFixBlob(&g_Element[0], sizeof(posix_spawnattr_t), sizeof(posix_spawnattr_t), + (char *)&attr); + s16 flag = *(s16 *)DT_SetGetS16(&g_Element[1], 0x123456); + posix_spawnattr_getflags((posix_spawnattr_t *)datainput, &flag); + } + DT_FUZZ_END(); + printf("end --- test_posix_spawnattr_getflags\n"); +} diff --git a/testsuites/fuzz/posix_spawnattr_getpgroup_fuzzer.cpp b/testsuites/fuzz/posix_spawnattr_getpgroup_fuzzer.cpp new file mode 100644 index 00000000..aef563c2 --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_getpgroup_fuzzer.cpp @@ -0,0 +1,46 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_posix_spawnattr_getpgroup(void) +{ + posix_spawnattr_t attr; + printf("start ---- test_posix_spawnattr_getpgroup\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_posix_spawnattr_getpgroup"), 0) + { + char *datainput = DT_SetGetFixBlob(&g_Element[0], sizeof(posix_spawnattr_t), sizeof(posix_spawnattr_t), + (char *)&attr); + s32 pgrp = *(s32 *)DT_SetGetS32(&g_Element[1], 0x123456); + posix_spawnattr_getpgroup((posix_spawnattr_t *)datainput, &pgrp); + } + DT_FUZZ_END(); + printf("end --- test_posix_spawnattr_getpgroup\n"); +} diff --git a/testsuites/fuzz/posix_spawnattr_getschedparam_fuzzer.cpp b/testsuites/fuzz/posix_spawnattr_getschedparam_fuzzer.cpp new file mode 100644 index 00000000..0ba30bfc --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_getschedparam_fuzzer.cpp @@ -0,0 +1,49 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include +#include + +void test_posix_spawnattr_getschedparam(void) +{ + posix_spawnattr_t attr; + struct sched_param schedparam; + printf("start ---- test_posix_spawnattr_getschedparam\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_posix_spawnattr_getschedparam"), 0) + { + char *datainput = DT_SetGetFixBlob(&g_Element[0], sizeof(posix_spawnattr_t), sizeof(posix_spawnattr_t), + (char *)&attr); + char *datainput1 = DT_SetGetFixBlob(&g_Element[1], sizeof(struct sched_param), sizeof(struct sched_param), + (char *)&schedparam); + posix_spawnattr_getschedparam((posix_spawnattr_t *)datainput, (struct sched_param *)datainput); + } + DT_FUZZ_END(); + printf("end --- test_posix_spawnattr_getschedparam\n"); +} diff --git a/testsuites/fuzz/posix_spawnattr_getschedpolicy_fuzzer.cpp b/testsuites/fuzz/posix_spawnattr_getschedpolicy_fuzzer.cpp new file mode 100644 index 00000000..2452a8f5 --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_getschedpolicy_fuzzer.cpp @@ -0,0 +1,46 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_posix_spawnattr_getschedpolicy(void) +{ + posix_spawnattr_t attr; + printf("start ---- test_posix_spawnattr_getschedpolicy\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_posix_spawnattr_getschedpolicy"), 0) + { + char *datainput = DT_SetGetFixBlob(&g_Element[0], sizeof(posix_spawnattr_t), sizeof(posix_spawnattr_t), + (char *)&attr); + s32 policy = *(s32 *)DT_SetGetS32(&g_Element[1], 0x123456); + posix_spawnattr_getschedpolicy((posix_spawnattr_t *)datainput, &policy); + } + DT_FUZZ_END(); + printf("end --- test_posix_spawnattr_getschedpolicy\n"); +} diff --git a/testsuites/fuzz/posix_spawnattr_getsigdefault_fuzzer.cpp b/testsuites/fuzz/posix_spawnattr_getsigdefault_fuzzer.cpp new file mode 100644 index 00000000..bdd4298a --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_getsigdefault_fuzzer.cpp @@ -0,0 +1,47 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_posix_spawnattr_getsigdefault(void) +{ + posix_spawnattr_t attr; + sigset_t signalset; + printf("start ---- test_posix_spawnattr_getsigdefault\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_posix_spawnattr_getsigdefault"), 0) + { + char *datainput = DT_SetGetFixBlob(&g_Element[0], sizeof(posix_spawnattr_t), sizeof(posix_spawnattr_t), + (char *)&attr); + char *datainput1 = DT_SetGetFixBlob(&g_Element[1], sizeof(signalset), sizeof(signalset), (char *)&signalset); + posix_spawnattr_getsigdefault((posix_spawnattr_t *)datainput, (sigset_t *)datainput1); + } + DT_FUZZ_END(); + printf("end --- test_posix_spawnattr_getsigdefault\n"); +} diff --git a/testsuites/fuzz/posix_spawnattr_getsigmask_fuzzer.cpp b/testsuites/fuzz/posix_spawnattr_getsigmask_fuzzer.cpp new file mode 100644 index 00000000..d53b3190 --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_getsigmask_fuzzer.cpp @@ -0,0 +1,47 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_posix_spawnattr_getsigmask(void) +{ + posix_spawnattr_t attr; + sigset_t signalset; + printf("start ---- test_posix_spawnattr_getsigmask\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_posix_spawnattr_getsigmask"), 0) + { + char *datainput = DT_SetGetFixBlob(&g_Element[0], sizeof(posix_spawnattr_t), sizeof(posix_spawnattr_t), + (char *)&attr); + char *datainput1 = DT_SetGetFixBlob(&g_Element[1], sizeof(sigset_t), sizeof(sigset_t), (char *)&signalset); + posix_spawnattr_getsigmask((posix_spawnattr_t *)datainput, (sigset_t *)datainput1); + } + DT_FUZZ_END(); + printf("end --- test_posix_spawnattr_getsigmask\n"); +} diff --git a/testsuites/fuzz/posix_spawnattr_init_fuzzer.cpp b/testsuites/fuzz/posix_spawnattr_init_fuzzer.cpp new file mode 100644 index 00000000..7ac37368 --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_init_fuzzer.cpp @@ -0,0 +1,45 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_posix_spawnattr_init(void) +{ + posix_spawnattr_t attr; + printf("start ---- test_posix_spawnattr_init\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_posix_spawnattr_init"), 0) + { + char *datainput = DT_SetGetFixBlob(&g_Element[0], sizeof(posix_spawnattr_t), sizeof(posix_spawnattr_t), + (char *)&attr); + posix_spawnattr_init((posix_spawnattr_t *)datainput); + } + DT_FUZZ_END(); + printf("end --- test_posix_spawnattr_init\n"); +} diff --git a/testsuites/fuzz/posix_spawnattr_setflags_fuzzer.cpp b/testsuites/fuzz/posix_spawnattr_setflags_fuzzer.cpp new file mode 100644 index 00000000..a93f76fa --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_setflags_fuzzer.cpp @@ -0,0 +1,46 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_posix_spawnattr_setflags(void) +{ + posix_spawnattr_t attr; + printf("start ---- test_posix_spawnattr_setflags\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_posix_spawnattr_setflags"), 0) + { + char *datainput = DT_SetGetFixBlob(&g_Element[0], sizeof(posix_spawnattr_t), sizeof(posix_spawnattr_t), + (char *)&attr); + s16 flags = *(s16 *)DT_SetGetS16(&g_Element[1], 0x123456); + posix_spawnattr_setflags((posix_spawnattr_t *)datainput, flags); + } + DT_FUZZ_END(); + printf("end --- test_posix_spawnattr_setflags\n"); +} \ No newline at end of file diff --git a/testsuites/fuzz/posix_spawnattr_setpgroup_fuzzer.cpp b/testsuites/fuzz/posix_spawnattr_setpgroup_fuzzer.cpp new file mode 100644 index 00000000..1e35ffa0 --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_setpgroup_fuzzer.cpp @@ -0,0 +1,46 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_posix_spawnattr_setpgroup(void) +{ + posix_spawnattr_t attr; + printf("start ---- test_posix_spawnattr_setpgroup\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_posix_spawnattr_setpgroup"), 0) + { + char *datainput = DT_SetGetFixBlob(&g_Element[0], sizeof(posix_spawnattr_t), sizeof(posix_spawnattr_t), + (char *)&attr); + s32 pgrp = *(s32 *)DT_SetGetS32(&g_Element[1], 0x123456); + posix_spawnattr_setpgroup((posix_spawnattr_t *)datainput, pgrp); + } + DT_FUZZ_END(); + printf("end --- test_posix_spawnattr_setpgroup\n"); +} \ No newline at end of file diff --git a/testsuites/fuzz/posix_spawnattr_setschedparam_fuzzer.cpp b/testsuites/fuzz/posix_spawnattr_setschedparam_fuzzer.cpp new file mode 100644 index 00000000..c2458f30 --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_setschedparam_fuzzer.cpp @@ -0,0 +1,49 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include +#include + +void test_posix_spawnattr_setschedparam(void) +{ + posix_spawnattr_t attr; + struct sched_param schedparam; + printf("start ---- test_posix_spawnattr_setschedparam\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_posix_spawnattr_setschedparam"), 0) + { + char *datainput = DT_SetGetFixBlob(&g_Element[0], sizeof(posix_spawnattr_t), sizeof(posix_spawnattr_t), + (char *)&attr); + char *datainput1 = DT_SetGetFixBlob(&g_Element[1], sizeof(struct sched_param), sizeof(struct sched_param), + (char *)&schedparam); + posix_spawnattr_setschedparam((posix_spawnattr_t *)datainput, (struct sched_param *)datainput1); + } + DT_FUZZ_END(); + printf("end --- test_posix_spawnattr_setschedparam\n"); +} \ No newline at end of file diff --git a/testsuites/fuzz/posix_spawnattr_setschedpolicy_fuzzer.cpp b/testsuites/fuzz/posix_spawnattr_setschedpolicy_fuzzer.cpp new file mode 100644 index 00000000..5f60291e --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_setschedpolicy_fuzzer.cpp @@ -0,0 +1,47 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include +#include + +void test_posix_spawnattr_setschedpolicy(void) +{ + posix_spawnattr_t attr; + printf("start ---- test_posix_spawnattr_setschedpolicy\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_posix_spawnattr_setschedpolicy"), 0) + { + char *datainput = DT_SetGetFixBlob(&g_Element[0], sizeof(posix_spawnattr_t), sizeof(posix_spawnattr_t), + (char *)&attr); + s32 policy = *(s32 *)DT_SetGetS32(&g_Element[1], 0x123456); + posix_spawnattr_setschedpolicy((posix_spawnattr_t *)datainput, policy); + } + DT_FUZZ_END(); + printf("end --- test_posix_spawnattr_setschedpolicy\n"); +} diff --git a/testsuites/fuzz/posix_spawnattr_setsigdefault_fuzzer.cpp b/testsuites/fuzz/posix_spawnattr_setsigdefault_fuzzer.cpp new file mode 100644 index 00000000..a5a6b161 --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_setsigdefault_fuzzer.cpp @@ -0,0 +1,47 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_posix_spawnattr_setsigdefault(void) +{ + posix_spawnattr_t attr; + sigset_t sigdefault; + printf("start ---- test_posix_spawnattr_setsigdefault\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_posix_spawnattr_setsigdefault"), 0) + { + char *datainput = DT_SetGetFixBlob(&g_Element[0], sizeof(posix_spawnattr_t), sizeof(posix_spawnattr_t), + (char *)&attr); + char *datainput1 = DT_SetGetFixBlob(&g_Element[1], sizeof(sigset_t), sizeof(sigset_t), (char *)&sigdefault); + posix_spawnattr_setsigdefault((posix_spawnattr_t *)datainput, (sigset_t *)datainput1); + } + DT_FUZZ_END(); + printf("end --- test_posix_spawnattr_setsigdefault\n"); +} diff --git a/testsuites/fuzz/posix_spawnattr_setsigmask_fuzzer.cpp b/testsuites/fuzz/posix_spawnattr_setsigmask_fuzzer.cpp new file mode 100644 index 00000000..a46b6e41 --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_setsigmask_fuzzer.cpp @@ -0,0 +1,47 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_posix_spawnattr_setsigmask(void) +{ + posix_spawnattr_t attr; + sigset_t signalset; + printf("start ---- test_posix_spawnattr_setsigmask\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_posix_spawnattr_setsigmask"), 0) + { + char *datainput = DT_SetGetFixBlob(&g_Element[0], sizeof(posix_spawnattr_t), sizeof(posix_spawnattr_t), + (char *)&attr); + char *datainput1 = DT_SetGetFixBlob(&g_Element[1], sizeof(sigset_t), sizeof(sigset_t), (char *)&signalset); + posix_spawnattr_setsigmask((posix_spawnattr_t *)datainput, (sigset_t *)datainput1); + } + DT_FUZZ_END(); + printf("end --- test_posix_spawnattr_setsigmask\n"); +} diff --git a/testsuites/fuzz/posix_spawnp_fuzzer.cpp b/testsuites/fuzz/posix_spawnp_fuzzer.cpp new file mode 100644 index 00000000..745a2358 --- /dev/null +++ b/testsuites/fuzz/posix_spawnp_fuzzer.cpp @@ -0,0 +1,45 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include +#include + +void test_posix_spawnp(void) +{ + printf("start ---- test_posix_spawnp\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_posix_spawnp"), 0) + { + s32 pid = *(s32 *)DT_SetGetS32(&g_Element[0], 0x123456); + char *argv[] = {"tftp", nullptr}; + posix_spawnp(&pid, "/bin/tftp", nullptr, nullptr, argv, nullptr); + } + DT_FUZZ_END(); + printf("end --- test_posix_spawnp\n"); +} diff --git a/testsuites/fuzz/pthread_mutex_consistent_fuzzer.cpp b/testsuites/fuzz/pthread_mutex_consistent_fuzzer.cpp new file mode 100644 index 00000000..180df2a8 --- /dev/null +++ b/testsuites/fuzz/pthread_mutex_consistent_fuzzer.cpp @@ -0,0 +1,45 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_pthread_mutex_consistent(void) +{ + pthread_mutex_t fa; + printf("start----pthread_mutex_consistent\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_pthread_mutex_consistent"), 0) + { + char *datainput = DT_SetGetFixBlob(&g_Element[0], sizeof(pthread_mutex_t), sizeof(pthread_mutex_t), + (char *)&fa); + pthread_mutex_consistent((pthread_mutex_t *)datainput); + } + DT_FUZZ_END() + printf("end----pthread_mutex_consistent\n"); +} diff --git a/testsuites/fuzz/pthread_mutex_getprioceiling_fuzzer.cpp b/testsuites/fuzz/pthread_mutex_getprioceiling_fuzzer.cpp new file mode 100644 index 00000000..45857e8f --- /dev/null +++ b/testsuites/fuzz/pthread_mutex_getprioceiling_fuzzer.cpp @@ -0,0 +1,49 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_pthread_mutex_getprioceiling(void) +{ + pthread_mutex_t g_muxLock; + printf("start----pthread_mutex_getprioceiling\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_pthread_mutex_getprioceiling"), 0) + { + char *datainput = DT_SetGetFixBlob(&g_Element[0], sizeof(pthread_mutex_t), sizeof(pthread_mutex_t), + (char *)&g_muxLock); + s32 number0 = *(s32 *)DT_SetGetS32(&g_Element[1], 0x123456); + pthread_mutex_init((pthread_mutex_t *)datainput, NULL); + pthread_mutex_setprioceiling((pthread_mutex_t *)datainput, number0, NULL); + pthread_mutex_getprioceiling((pthread_mutex_t *)datainput, &number0); + pthread_mutex_destroy((pthread_mutex_t *)datainput); + } + DT_FUZZ_END(); + printf("end----pthread_mutex_getprioceiling\n"); +} diff --git a/testsuites/fuzz/pthread_mutexattr_setprotocol_fuzzer.cpp b/testsuites/fuzz/pthread_mutexattr_setprotocol_fuzzer.cpp new file mode 100644 index 00000000..a18dc958 --- /dev/null +++ b/testsuites/fuzz/pthread_mutexattr_setprotocol_fuzzer.cpp @@ -0,0 +1,46 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_pthread_mutexattr_setprotocol(void) +{ + pthread_mutexattr_t fa; + printf("start----pthread_mutexattr_setprotocol\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_pthread_mutexattr_setprotocol"), 0) + { + char *datainput = DT_SetGetFixBlob(&g_Element[0], sizeof(pthread_mutexattr_t), sizeof(pthread_mutexattr_t), + (char *)&fa); + s32 number = *(s32 *)DT_SetGetS32(&g_Element[1], 0x123456); + pthread_mutexattr_setprotocol((pthread_mutexattr_t *)datainput, number); + } + DT_FUZZ_END() + printf("end----pthread_mutexattr_setprotocol\n"); +} diff --git a/testsuites/fuzz/pthread_mutexattr_setrobust_fuzzer.cpp b/testsuites/fuzz/pthread_mutexattr_setrobust_fuzzer.cpp new file mode 100644 index 00000000..985739e0 --- /dev/null +++ b/testsuites/fuzz/pthread_mutexattr_setrobust_fuzzer.cpp @@ -0,0 +1,46 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_pthread_mutexattr_setrobust(void) +{ + pthread_mutexattr_t fa; + printf("start----pthread_mutexattr_setrobust\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_pthread_mutexattr_setrobust"), 0) + { + char *datainput = DT_SetGetFixBlob(&g_Element[0], sizeof(pthread_mutexattr_t), sizeof(pthread_mutexattr_t), + (char *)&fa); + s32 number = *(s32 *)DT_SetGetS32(&g_Element[1], 0x123456); + pthread_mutexattr_setrobust((pthread_mutexattr_t *)datainput, number); + } + DT_FUZZ_END() + printf("end----pthread_mutexattr_setrobust\n"); +} diff --git a/testsuites/fuzz/pthread_mutexattr_settype_fuzzer.cpp b/testsuites/fuzz/pthread_mutexattr_settype_fuzzer.cpp new file mode 100644 index 00000000..0efb8a91 --- /dev/null +++ b/testsuites/fuzz/pthread_mutexattr_settype_fuzzer.cpp @@ -0,0 +1,46 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +void test_pthread_mutexattr_settype(void) +{ + pthread_mutexattr_t fa; + printf("start----pthread_mutexattr_settype\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_pthread_mutexattr_settype"), 0) + { + char *datainput = DT_SetGetFixBlob(&g_Element[0], sizeof(pthread_mutexattr_t), sizeof(pthread_mutexattr_t), + (char *)&fa); + s32 number = *(s32 *)DT_SetGetS32(&g_Element[1], 0x123456); + pthread_mutexattr_settype((pthread_mutexattr_t *)datainput, number); + } + DT_FUZZ_END() + printf("end----pthread_mutexattr_settype\n"); +} diff --git a/testsuites/fuzz/pthread_setconcurrency_fuzzer.cpp b/testsuites/fuzz/pthread_setconcurrency_fuzzer.cpp new file mode 100644 index 00000000..e0e0e5e7 --- /dev/null +++ b/testsuites/fuzz/pthread_setconcurrency_fuzzer.cpp @@ -0,0 +1,42 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include + +void test_pthread_setconcurrency(void) +{ + printf("start----pthread_setconcurrency\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_pthread_setconcurrency"), 0) + { + s32 number = *(s32 *)DT_SetGetS32(&g_Element[0], 0x123456); + pthread_setconcurrency(number); + } + DT_FUZZ_END() + printf("end----pthread_setconcurrency\n"); +} diff --git a/testsuites/fuzz/readlink_fuzzer.cpp b/testsuites/fuzz/readlink_fuzzer.cpp new file mode 100644 index 00000000..9cb7ce97 --- /dev/null +++ b/testsuites/fuzz/readlink_fuzzer.cpp @@ -0,0 +1,44 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include + +void test_readlink(void) +{ + printf("start----readlink\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_readlink"), 0) + { + char *pathname = DT_SetGetBlob(&g_Element[0], 6, 10000, "123456"); + char *buf = DT_SetGetBlob(&g_Element[1], 6, 10000, "123456"); + int bufsize = DT_GET_MutatedValueLen(&g_Element[1]); + readlink(pathname, buf, bufsize); + } + DT_FUZZ_END() + printf("end----readlink\n"); +} diff --git a/testsuites/fuzz/readlinkat_fuzzer.cpp b/testsuites/fuzz/readlinkat_fuzzer.cpp new file mode 100644 index 00000000..96bb13b9 --- /dev/null +++ b/testsuites/fuzz/readlinkat_fuzzer.cpp @@ -0,0 +1,45 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include + +void test_readlinkatat(void) +{ + printf("start----readlinkat\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 1000, const_cast("test_readlinkatat"), 0) + { + s32 dirfd = *(s32*)DT_SetGetS32(&g_Element[0], 0x123456); + char *pathname = DT_SetGetBlob(&g_Element[1], 6, 10000, "123456"); + char *buf = DT_SetGetBlob(&g_Element[2], 6, 10000, "123456"); + int bufsize = DT_GET_MutatedValueLen(&g_Element[2]); + readlinkat(dirfd, pathname, buf, bufsize); + } + DT_FUZZ_END() + printf("end----readlinkat\n"); +} diff --git a/testsuites/fuzz/sem_open_fuzzer.cpp b/testsuites/fuzz/sem_open_fuzzer.cpp new file mode 100644 index 00000000..e0ec8723 --- /dev/null +++ b/testsuites/fuzz/sem_open_fuzzer.cpp @@ -0,0 +1,43 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include "gtest/gtest.h" + +void test_sem_open(void) +{ + printf("start ---- test_sem_open\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_sem_open"), 0) + { + char *buf = DT_SetGetString(&g_Element[0], 6, 10000, "123456"); + sem_open(buf, O_CREAT | O_EXCL, 0700, 1); + } + DT_FUZZ_END(); + printf("end --- test_sem_open\n"); +} diff --git a/testsuites/fuzz/setns_fuzzer.cpp b/testsuites/fuzz/setns_fuzzer.cpp new file mode 100644 index 00000000..568b1f16 --- /dev/null +++ b/testsuites/fuzz/setns_fuzzer.cpp @@ -0,0 +1,43 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include + +void test_setns(void) +{ + printf("start----test_setns\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_setns"), 0) + { + s32 number0 = *(s32 *)DT_SetGetS32(&g_Element[0], 0x123456); + s32 number1 = *(s32 *)DT_SetGetS32(&g_Element[1], 0x123456); + setns(number0, number1); + } + DT_FUZZ_END() + printf("end----test_setns\n"); +} diff --git a/testsuites/fuzz/syslog_fuzzer.cpp b/testsuites/fuzz/syslog_fuzzer.cpp new file mode 100644 index 00000000..c04f1b34 --- /dev/null +++ b/testsuites/fuzz/syslog_fuzzer.cpp @@ -0,0 +1,43 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include + +void test_syslog(void) +{ + printf("start----test_syslog\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_syslog"), 0) + { + s32 number = *(s32 *)DT_SetGetS32(&g_Element[0], 0x123456); + char *buf = DT_SetGetString(&g_Element[1], 6, 10000, "123456"); + syslog(number, "%s\n", buf); + } + DT_FUZZ_END() + printf("end----test_syslog\n"); +} diff --git a/testsuites/fuzz/system_fuzzer.cpp b/testsuites/fuzz/system_fuzzer.cpp new file mode 100644 index 00000000..f06a779c --- /dev/null +++ b/testsuites/fuzz/system_fuzzer.cpp @@ -0,0 +1,43 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include + +void test_system(void) +{ + printf("start----test_system\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_system"), 0) + { + char *buf = DT_SetGetString(&g_Element[0], 6, 10000, "123456"); + printf("buf: %s\n",buf); + system(buf); + } + DT_FUZZ_END() + printf("end----test_system\n"); +} diff --git a/testsuites/fuzz/times_fuzzer.cpp b/testsuites/fuzz/times_fuzzer.cpp new file mode 100644 index 00000000..ee4cb1c7 --- /dev/null +++ b/testsuites/fuzz/times_fuzzer.cpp @@ -0,0 +1,45 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include +#include + +void test_times(void) +{ + struct tms buf; + printf("start----test_times\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_times"), 0) + { + char *datainput = DT_SetGetFixBlob(&g_Element[0], sizeof(struct tms), sizeof(struct tms), (char *)&buf); + times((struct tms *)datainput); + } + DT_FUZZ_END() + printf("end----test_times\n"); +} diff --git a/testsuites/fuzz/unshare_fuzzer.cpp b/testsuites/fuzz/unshare_fuzzer.cpp new file mode 100644 index 00000000..02b05878 --- /dev/null +++ b/testsuites/fuzz/unshare_fuzzer.cpp @@ -0,0 +1,42 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include + +void test_unshare(void) +{ + printf("start----test_unshare\n"); + DT_Enable_Support_Loop(1); + DT_FUZZ_START(0, 100000, const_cast("test_unshare"), 0) + { + s32 number = *(s32 *)DT_SetGetS32(&g_Element[0], 0x123456); + unshare(number); + } + DT_FUZZ_END() + printf("end----test_unshare\n"); +} -- Gitee