From 272c49061877617efab87a2254f8ce6e6f2df4bf Mon Sep 17 00:00:00 2001 From: gaorui Date: Fri, 3 Feb 2023 15:03:44 +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 | 88 ++++++++++++ testsuites/fuzz/adjtime_fuzzer.cpp | 48 +++++++ testsuites/fuzz/chroot_fuzzer.cpp | 46 ++++++ testsuites/fuzz/clone_fuzzer.cpp | 58 ++++++++ testsuites/fuzz/epoll_create_fuzzer.cpp | 46 ++++++ testsuites/fuzz/epoll_ctl_fuzzer.cpp | 51 +++++++ testsuites/fuzz/epoll_wait_fuzzer.cpp | 51 +++++++ testsuites/fuzz/fesetenv_fuzzer.cpp | 47 +++++++ testsuites/fuzz/fuzzertest.h | 25 ++++ testsuites/fuzz/getrlimit_fuzzer.cpp | 48 +++++++ testsuites/fuzz/main.cpp | 133 ++++++++++++++++++ testsuites/fuzz/mlock_fuzzer.cpp | 48 +++++++ testsuites/fuzz/mlockall_fuzzer.cpp | 46 ++++++ ..._spawn_file_actions_addchdir_np_fuzzer.cpp | 55 ++++++++ ...osix_spawn_file_actions_adddup2_fuzzer.cpp | 56 ++++++++ ...spawn_file_actions_addfchdir_np_fuzzer.cpp | 55 ++++++++ ...osix_spawn_file_actions_addopen_fuzzer.cpp | 58 ++++++++ ...osix_spawn_file_actions_destroy_fuzzer.cpp | 55 ++++++++ .../posix_spawn_file_actions_init_fuzzer.cpp | 54 +++++++ testsuites/fuzz/posix_spawn_fuzzer.cpp | 48 +++++++ .../fuzz/posix_spawnattr_destroy_fuzzer.cpp | 48 +++++++ .../fuzz/posix_spawnattr_getflags_fuzzer.cpp | 49 +++++++ .../fuzz/posix_spawnattr_getpgroup_fuzzer.cpp | 49 +++++++ .../posix_spawnattr_getschedparam_fuzzer.cpp | 51 +++++++ .../posix_spawnattr_getschedpolicy_fuzzer.cpp | 49 +++++++ .../posix_spawnattr_getsigdefault_fuzzer.cpp | 50 +++++++ .../posix_spawnattr_getsigmask_fuzzer.cpp | 50 +++++++ .../fuzz/posix_spawnattr_init_fuzzer.cpp | 48 +++++++ .../fuzz/posix_spawnattr_setflags_fuzzer.cpp | 49 +++++++ .../fuzz/posix_spawnattr_setpgroup_fuzzer.cpp | 48 +++++++ .../posix_spawnattr_setschedparam_fuzzer.cpp | 52 +++++++ .../posix_spawnattr_setschedpolicy_fuzzer.cpp | 50 +++++++ .../posix_spawnattr_setsigdefault_fuzzer.cpp | 50 +++++++ .../posix_spawnattr_setsigmask_fuzzer.cpp | 50 +++++++ testsuites/fuzz/posix_spawnp_fuzzer.cpp | 48 +++++++ .../fuzz/pthread_mutex_consistent_fuzzer.cpp | 48 +++++++ .../pthread_mutex_getprioceiling_fuzzer.cpp | 52 +++++++ .../pthread_mutexattr_setprotocol_fuzzer.cpp | 49 +++++++ .../pthread_mutexattr_setrobust_fuzzer.cpp | 49 +++++++ .../fuzz/pthread_mutexattr_settype_fuzzer.cpp | 49 +++++++ .../fuzz/pthread_setconcurrency_fuzzer.cpp | 46 ++++++ testsuites/fuzz/readlink_fuzzer.cpp | 48 +++++++ testsuites/fuzz/readlinkat_fuzzer.cpp | 50 +++++++ testsuites/fuzz/sem_open_fuzzer.cpp | 48 +++++++ testsuites/fuzz/sethostname_fuzzer.cpp | 47 +++++++ testsuites/fuzz/setns_fuzzer.cpp | 47 +++++++ testsuites/fuzz/syslog_fuzzer.cpp | 47 +++++++ testsuites/fuzz/system_fuzzer.cpp | 46 ++++++ testsuites/fuzz/times_fuzzer.cpp | 48 +++++++ testsuites/fuzz/unshare_fuzzer.cpp | 46 ++++++ 51 files changed, 2578 insertions(+) create mode 100644 testsuites/fuzz/BUILD.gn create mode 100644 testsuites/fuzz/adjtime_fuzzer.cpp create mode 100644 testsuites/fuzz/chroot_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/fuzzertest.h 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/sethostname_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..2d8bccbe --- /dev/null +++ b/testsuites/fuzz/BUILD.gn @@ -0,0 +1,88 @@ +# 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", + "chroot_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", + "sethostname_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..294a91d7 --- /dev/null +++ b/testsuites/fuzz/adjtime_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 +#include "fuzzertest.h" + +void TestAdjtime(void) +{ + struct timeval fa; + printf("start----TestAdjtime\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestAdjtime"), 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----TestAdjtime\n"); +} diff --git a/testsuites/fuzz/chroot_fuzzer.cpp b/testsuites/fuzz/chroot_fuzzer.cpp new file mode 100644 index 00000000..4db53e36 --- /dev/null +++ b/testsuites/fuzz/chroot_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 +#include "fuzzertest.h" + +void TestChroot(void) +{ + printf("start----TestChroot\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestChroot"), 0) { + char *buf = DT_SetGetString(&g_Element[0], LENGTH_STRING, MAXLENGTH_STRING, INITVALUE_STRING); + chroot(buf); + } + DT_FUZZ_END() + printf("end----TestChroot\n"); +} diff --git a/testsuites/fuzz/clone_fuzzer.cpp b/testsuites/fuzz/clone_fuzzer.cpp new file mode 100644 index 00000000..2ac95f6b --- /dev/null +++ b/testsuites/fuzz/clone_fuzzer.cpp @@ -0,0 +1,58 @@ +/* + * 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 +#include "fuzzertest.h" + +static int childFunc(void *) +{ + return 0; +} + +void TestClone(void) +{ + printf("start----TestClone\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestClone"), 0) { + s32 number = *(s32 *)DT_SetGetS32(&g_Element[0], INITVALUE_S32); + pid_t pid = clone(childFunc, NULL, number, NULL); + waitpid(pid, NULL, 0); + } + DT_FUZZ_END() + printf("end----TestClone\n"); +} diff --git a/testsuites/fuzz/epoll_create_fuzzer.cpp b/testsuites/fuzz/epoll_create_fuzzer.cpp new file mode 100644 index 00000000..9a143a90 --- /dev/null +++ b/testsuites/fuzz/epoll_create_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 +#include "fuzzertest.h" + +void TestEpollCreate(void) +{ + printf("start----TestEpollCreate\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestEpollCreate"), 0) { + s32 number = *(s32 *)DT_SetGetS32(&g_Element[0], INITVALUE_S32); + epoll_create(number); + } + DT_FUZZ_END() + printf("end----TestEpollCreate\n"); +} diff --git a/testsuites/fuzz/epoll_ctl_fuzzer.cpp b/testsuites/fuzz/epoll_ctl_fuzzer.cpp new file mode 100644 index 00000000..1312df5d --- /dev/null +++ b/testsuites/fuzz/epoll_ctl_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 +#include "fuzzertest.h" + +void TestEpollCtl(void) +{ + struct epoll_event fa; + printf("start----TestEpollCtl\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestEpollCtl"), 0) { + s32 number0 = *(s32 *)DT_SetGetS32(&g_Element[0], INITVALUE_S32); + s32 number1 = *(s32 *)DT_SetGetS32(&g_Element[1], INITVALUE_S32); + s32 number2 = *(s32 *)DT_SetGetS32(&g_Element[2], INITVALUE_S32); + 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----TestEpollCtl\n"); +} diff --git a/testsuites/fuzz/epoll_wait_fuzzer.cpp b/testsuites/fuzz/epoll_wait_fuzzer.cpp new file mode 100644 index 00000000..1bdb16f7 --- /dev/null +++ b/testsuites/fuzz/epoll_wait_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 +#include "fuzzertest.h" + +void TestEpollWait(void) +{ + struct epoll_event fa; + printf("start----TestEpollWait\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestEpollWait"), 0) { + s32 number0 = *(s32 *)DT_SetGetS32(&g_Element[0], INITVALUE_S32); + s32 number1 = *(s32 *)DT_SetGetS32(&g_Element[1], INITVALUE_S32); + s32 number2 = *(s32 *)DT_SetGetS32(&g_Element[2], INITVALUE_S32); + 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----TestEpollWait\n"); +} diff --git a/testsuites/fuzz/fesetenv_fuzzer.cpp b/testsuites/fuzz/fesetenv_fuzzer.cpp new file mode 100644 index 00000000..7df96707 --- /dev/null +++ b/testsuites/fuzz/fesetenv_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 "fuzzertest.h" + +void TestFesetenv(void) +{ + fenv_t fa; + printf("start----TestFesetenv\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestFesetenv"), 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----TestFesetenv\n"); +} diff --git a/testsuites/fuzz/fuzzertest.h b/testsuites/fuzz/fuzzertest.h new file mode 100644 index 00000000..559b452b --- /dev/null +++ b/testsuites/fuzz/fuzzertest.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _FUZZERTEST_H +#define _FUZZERTEST_H + +#define FREQUENCY 100000 +#define INITVALUE_S32 0x123456 +#define INITVALUE_STRING "123456" +#define LENGTH_STRING 6 +#define MAXLENGTH_STRING 10000 + +#endif \ No newline at end of file diff --git a/testsuites/fuzz/getrlimit_fuzzer.cpp b/testsuites/fuzz/getrlimit_fuzzer.cpp new file mode 100644 index 00000000..20af5126 --- /dev/null +++ b/testsuites/fuzz/getrlimit_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 +#include "fuzzertest.h" + +void TestGetrlimit(void) +{ + struct rlimit fa; + printf("start----TestGetrlimit\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestGetrlimit"), 0) { + s32 resource = *(s32 *)DT_SetGetS32(&g_Element[0], INITVALUE_S32); + 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----TestGetrlimit\n"); +} diff --git a/testsuites/fuzz/main.cpp b/testsuites/fuzz/main.cpp new file mode 100644 index 00000000..83b7b758 --- /dev/null +++ b/testsuites/fuzz/main.cpp @@ -0,0 +1,133 @@ +/* + * 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 TestPosixSpawnFileActionsAddchdirNp(void); +extern void TestPosixSpawnFileActionsAdddup2(void); +extern void TestPosixSpawnFileActionsAddfchdirNp(void); +extern void TestPosixSpawnFileActionsAddopen(void); +extern void TestPosixSpawnFileActionsDestroy(void); +extern void TestPosixSpawnFileActionsInit(void); +extern void TestPosixSpawn(void); +extern void TestPosixSpawnattrDestroy(void); +extern void TestPosixSpawnattrGetflags(void); +extern void TestPosixSpawnattrGetpgroup(void); +extern void TestPosixSpawnattrGetschedparam(void); +extern void TestPosixSpawnattrGetschedpolicy(void); +extern void TestPosixSpawnattrGetsigdefault(void); +extern void TestPosixSpawnattrGetsigmask(void); +extern void TestPosixSpawnattrInit(void); +extern void TestPosixSpawnattrSetflags(void); +extern void TestPosixSpawnattrSetpgroup(void); +extern void TestPosixSpawnattrSetschedparam(void); +extern void TestPosixSpawnattrSetschedpolicy(void); +extern void TestPosixSpawnattrSetsigdefault(void); +extern void TestPosixSpawnattrSetsigmask(void); +extern void TestPosixSpawnp(void); +extern void TestAdjtime(void); +extern void TestFesetenv(void); +extern void TestGetrlimit(void); +extern void TestReadlink(void); +extern void TestReadlinkat(void); +extern void TestSyslog(void); +extern void TestSystem(void); +extern void TestTimes(void); +extern void TestClone(void); +extern void TestEpollCreate(void); +extern void TestEpollCtl(void); +extern void TestEpollWait(void); +extern void TestMlock(void); +extern void TestMlockall(void); +extern void TestPthreadMutexConsistent(void); +extern void TestPthreadMutexGetprioceiling(void); +extern void TestPthreadMutexattrSetprotocol(void); +extern void TestPthreadMutexattrSetrobust(void); +extern void TestPthreadMutexattrSettype(void); +extern void TestPthreadSetconcurrency(void); +extern void TestSetns(void); +extern void TestUnshare(void); +extern void TestSemOpen(void); +extern void TestChroot(void); +extern void TestSethostname(void); + +int main() +{ + DT_Set_Report_Path("/storage/"); + TestPosixSpawnFileActionsAddchdirNp(); + TestPosixSpawnFileActionsAddopen(); + TestPosixSpawnFileActionsAdddup2(); + TestPosixSpawnFileActionsAddfchdirNp(); + TestPosixSpawnFileActionsDestroy(); + TestPosixSpawnFileActionsInit(); + TestPosixSpawnattrDestroy(); + TestPosixSpawnattrGetflags(); + TestPosixSpawnattrGetpgroup(); + TestPosixSpawnattrGetschedparam(); + TestPosixSpawnattrGetschedpolicy(); + TestPosixSpawnattrGetsigdefault(); + TestPosixSpawnattrGetsigmask(); + TestPosixSpawnattrInit(); + TestPosixSpawnattrSetflags(); + TestPosixSpawnattrSetpgroup(); + TestPosixSpawnattrSetschedparam(); + TestPosixSpawnattrSetschedpolicy(); + TestPosixSpawnattrSetsigdefault(); + TestPosixSpawnattrSetsigmask(); + TestPosixSpawn(); + TestPosixSpawnp(); + TestSyslog(); + TestSystem(); + TestMlock(); + TestMlockall(); + TestAdjtime(); + TestFesetenv(); + TestGetrlimit(); + TestReadlink(); + TestReadlinkat(); + TestTimes(); + TestClone(); + TestEpollCreate(); + TestEpollCtl(); + TestEpollWait(); + TestPthreadMutexConsistent(); + TestPthreadMutexGetprioceiling(); + TestPthreadMutexattrSetprotocol(); + TestPthreadMutexattrSetrobust(); + TestPthreadMutexattrSettype(); + TestPthreadSetconcurrency(); + TestSetns(); + TestSemOpen(); + TestUnshare(); + TestChroot(); + TestSethostname(); + + return 0; +} diff --git a/testsuites/fuzz/mlock_fuzzer.cpp b/testsuites/fuzz/mlock_fuzzer.cpp new file mode 100644 index 00000000..06169988 --- /dev/null +++ b/testsuites/fuzz/mlock_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 +#include "fuzzertest.h" + +void TestMlock(void) +{ + int lockSize = 4096 + 1; + printf("start----TestMlock\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestMlock"), 0) { + char *p = DT_SetGetString(&g_Element[0], LENGTH_STRING, MAXLENGTH_STRING, INITVALUE_STRING); + mlock(p, lockSize); + munlock(p, lockSize); + } + DT_FUZZ_END() + printf("end----TestMlock\n"); +} diff --git a/testsuites/fuzz/mlockall_fuzzer.cpp b/testsuites/fuzz/mlockall_fuzzer.cpp new file mode 100644 index 00000000..c9c35f45 --- /dev/null +++ b/testsuites/fuzz/mlockall_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 +#include "fuzzertest.h" + +void TestMlockall(void) +{ + printf("start----TestMlockall\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestMlockall"), 0) { + s32 number = *(s32 *)DT_SetGetS32(&g_Element[0], INITVALUE_S32); + mlockall(number); + } + DT_FUZZ_END() + printf("end----TestMlockall\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..bef1a865 --- /dev/null +++ b/testsuites/fuzz/posix_spawn_file_actions_addchdir_np_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 +#include "fuzzertest.h" + +void TestPosixSpawnFileActionsAddchdirNp(void) +{ + posix_spawn_file_actions_t fa; + printf("start ---- TestPosixSpawnFileActionsAddchdirNp\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPosixSpawnFileActionsAddchdirNp"), 0) { + fa.__pad0[0] = *(s32 *)DT_SetGetS32(&g_Element[0], INITVALUE_S32); + fa.__pad0[1] = *(s32 *)DT_SetGetS32(&g_Element[1], INITVALUE_S32); + fa.__pad0[2] = *(s32 *)DT_SetGetS32(&g_Element[2], INITVALUE_S32); + for (int i = 0; i < 16; i++) { + fa.__pad[i] = *(s32 *)DT_SetGetS32(&g_Element[i+3], INITVALUE_S32); + } + char *action = DT_SetGetBlob(&g_Element[18], LENGTH_STRING, MAXLENGTH_STRING, INITVALUE_STRING); + fa.__actions=(void *)action; + char *path = DT_SetGetString(&g_Element[19], LENGTH_STRING, MAXLENGTH_STRING, INITVALUE_STRING); + posix_spawn_file_actions_addchdir_np(&fa, path); + } + DT_FUZZ_END(); + printf("end --- TestPosixSpawnFileActionsAddchdirNp\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..d7b877eb --- /dev/null +++ b/testsuites/fuzz/posix_spawn_file_actions_adddup2_fuzzer.cpp @@ -0,0 +1,56 @@ +/* + * 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" +#include "fuzzertest.h" + +void TestPosixSpawnFileActionsAdddup2(void) +{ + posix_spawn_file_actions_t fa; + printf("start ---- TestPosixSpawnFileActionsAdddup2\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPosixSpawnFileActionsAdddup2"), 0) { + fa.__pad0[0] = *(s32 *)DT_SetGetS32(&g_Element[0], INITVALUE_S32); + fa.__pad0[1] = *(s32 *)DT_SetGetS32(&g_Element[1], INITVALUE_S32); + fa.__pad0[2] = *(s32 *)DT_SetGetS32(&g_Element[2], INITVALUE_S32); + for (int i = 0; i < 16; i++) { + fa.__pad[i] = *(s32 *)DT_SetGetS32(&g_Element[i+3], INITVALUE_S32); + } + char *action = DT_SetGetBlob(&g_Element[18], LENGTH_STRING, MAXLENGTH_STRING, INITVALUE_STRING); + fa.__actions=(void *)action; + s32 tmpfd = *(s32 *)DT_SetGetS32(&g_Element[19], INITVALUE_S32); + posix_spawn_file_actions_adddup2(&fa, STDOUT_FILENO, tmpfd); + } + DT_FUZZ_END(); + printf("end --- TestPosixSpawnFileActionsAdddup2\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..894e6283 --- /dev/null +++ b/testsuites/fuzz/posix_spawn_file_actions_addfchdir_np_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 +#include "fuzzertest.h" + +void TestPosixSpawnFileActionsAddfchdirNp(void) +{ + posix_spawn_file_actions_t fa; + printf("start ---- TestPosixSpawnFileActionsAddfchdirNp\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPosixSpawnFileActionsAddfchdirNp"), 0) { + fa.__pad0[0] = *(s32 *)DT_SetGetS32(&g_Element[0], INITVALUE_S32); + fa.__pad0[1] = *(s32 *)DT_SetGetS32(&g_Element[1], INITVALUE_S32); + fa.__pad0[2] = *(s32 *)DT_SetGetS32(&g_Element[2], INITVALUE_S32); + for (int i = 0; i < 16; i++) { + fa.__pad[i] = *(s32 *)DT_SetGetS32(&g_Element[i+3], INITVALUE_S32); + } + char *action = DT_SetGetBlob(&g_Element[18], LENGTH_STRING, MAXLENGTH_STRING, INITVALUE_STRING); + fa.__actions=(void *)action; + s32 tmpfd = *(s32 *)DT_SetGetS32(&g_Element[19], INITVALUE_S32); + posix_spawn_file_actions_addfchdir_np(&fa, tmpfd); + } + DT_FUZZ_END(); + printf("end --- TestPosixSpawnFileActionsAddfchdirNp\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..5310b781 --- /dev/null +++ b/testsuites/fuzz/posix_spawn_file_actions_addopen_fuzzer.cpp @@ -0,0 +1,58 @@ +/* + * 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 "fuzzertest.h" + +void TestPosixSpawnFileActionsAddopen(void) +{ + posix_spawn_file_actions_t fa; + printf("start ---- TestPosixSpawnFileActionsAddopen\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPosixSpawnFileActionsAddopen"), 0) { + fa.__pad0[0] = *(s32 *)DT_SetGetS32(&g_Element[0], INITVALUE_S32); + fa.__pad0[1] = *(s32 *)DT_SetGetS32(&g_Element[1], INITVALUE_S32); + fa.__pad0[2] = *(s32 *)DT_SetGetS32(&g_Element[2], INITVALUE_S32); + for (int i = 0; i < 16; i++) { + fa.__pad[i] = *(s32 *)DT_SetGetS32(&g_Element[i+3], INITVALUE_S32); + } + char *action = DT_SetGetBlob(&g_Element[18], LENGTH_STRING, MAXLENGTH_STRING, INITVALUE_STRING); + fa.__actions=(void *)action; + s32 tmpfd = *(s32 *)DT_SetGetS32(&g_Element[19], INITVALUE_S32); + char *path = DT_SetGetBlob(&g_Element[20], LENGTH_STRING, MAXLENGTH_STRING, INITVALUE_STRING); + s32 flag = *(s32 *)DT_SetGetS32(&g_Element[21], INITVALUE_S32); + posix_spawn_file_actions_addopen(&fa, tmpfd, path, flag, 0); + posix_spawn_file_actions_addclose(&fa, tmpfd); + } + DT_FUZZ_END(); + printf("end --- TestPosixSpawnFileActionsAddopen\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..1acd5089 --- /dev/null +++ b/testsuites/fuzz/posix_spawn_file_actions_destroy_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 +#include "fuzzertest.h" + +void TestPosixSpawnFileActionsDestroy(void) +{ + posix_spawn_file_actions_t fa; + printf("start ---- TestPosixSpawnFileActionsDestroy\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPosixSpawnFileActionsDestroy"), 0) { + fa.__pad0[0] = *(s32 *)DT_SetGetS32(&g_Element[0], INITVALUE_S32); + fa.__pad0[1] = *(s32 *)DT_SetGetS32(&g_Element[1], INITVALUE_S32); + fa.__pad0[2] = *(s32 *)DT_SetGetS32(&g_Element[2], INITVALUE_S32); + for (int i = 0; i < 16; i++) { + fa.__pad[i] = *(s32 *)DT_SetGetS32(&g_Element[i+3], INITVALUE_S32); + } + char *action = DT_SetGetBlob(&g_Element[18], LENGTH_STRING, MAXLENGTH_STRING, INITVALUE_STRING); + fa.__actions=(void *)action; + posix_spawn_file_actions_init(&fa); + posix_spawn_file_actions_destroy(&fa); + } + DT_FUZZ_END(); + printf("end --- TestPosixSpawnFileActionsDestroy\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..d62edb05 --- /dev/null +++ b/testsuites/fuzz/posix_spawn_file_actions_init_fuzzer.cpp @@ -0,0 +1,54 @@ +/* + * 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 "fuzzertest.h" + +void TestPosixSpawnFileActionsInit(void) +{ + posix_spawn_file_actions_t fa; + printf("start ---- TestPosixSpawnFileActionsInit\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPosixSpawnFileActionsInit"), 0) { + fa.__pad0[0] = *(s32 *)DT_SetGetS32(&g_Element[0], INITVALUE_S32); + fa.__pad0[1] = *(s32 *)DT_SetGetS32(&g_Element[1], INITVALUE_S32); + fa.__pad0[2] = *(s32 *)DT_SetGetS32(&g_Element[2], INITVALUE_S32); + for (int i = 0; i < 16; i++) { + fa.__pad[i] = *(s32 *)DT_SetGetS32(&g_Element[i+3], INITVALUE_S32); + } + char *action = DT_SetGetBlob(&g_Element[18], LENGTH_STRING, MAXLENGTH_STRING, INITVALUE_STRING); + fa.__actions=(void *)action; + posix_spawn_file_actions_init(&fa); + } + DT_FUZZ_END(); + printf("end --- TestPosixSpawnFileActionsInit\n"); +} diff --git a/testsuites/fuzz/posix_spawn_fuzzer.cpp b/testsuites/fuzz/posix_spawn_fuzzer.cpp new file mode 100644 index 00000000..20285647 --- /dev/null +++ b/testsuites/fuzz/posix_spawn_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 +#include +#include "fuzzertest.h" + +void TestPosixSpawn(void) +{ + printf("start ---- TestPosixSpawn\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPosixSpawn"), 0) { + s32 pid = *(s32 *)DT_SetGetS32(&g_Element[0], INITVALUE_S32); + char *argv[] = {"tftp", nullptr}; + posix_spawn(&pid, "/bin/tftp", nullptr, nullptr, argv, nullptr); + } + DT_FUZZ_END(); + printf("end --- TestPosixSpawn\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..c9da6ad1 --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_destroy_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 +#include "fuzzertest.h" + +void TestPosixSpawnattrDestroy(void) +{ + posix_spawnattr_t attr; + printf("start ---- TestPosixSpawnattrDestroy\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPosixSpawnattrDestroy"), 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 --- TestPosixSpawnattrDestroy\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..ed299f63 --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_getflags_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 "fuzzertest.h" + +void TestPosixSpawnattrGetflags(void) +{ + posix_spawnattr_t attr; + printf("start ---- TestPosixSpawnattrGetflags\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPosixSpawnattrGetflags"), 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], INITVALUE_S32); + posix_spawnattr_getflags((posix_spawnattr_t *)datainput, &flag); + } + DT_FUZZ_END(); + printf("end --- TestPosixSpawnattrGetflags\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..12e92060 --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_getpgroup_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 "fuzzertest.h" + +void TestPosixSpawnattrGetpgroup(void) +{ + posix_spawnattr_t attr; + printf("start ---- TestPosixSpawnattrGetpgroup\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPosixSpawnattrGetpgroup"), 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], INITVALUE_S32); + posix_spawnattr_getpgroup((posix_spawnattr_t *)datainput, &pgrp); + } + DT_FUZZ_END(); + printf("end --- TestPosixSpawnattrGetpgroup\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..90b0b06b --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_getschedparam_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 +#include +#include "fuzzertest.h" + +void TestPosixSpawnattrGetschedparam(void) +{ + posix_spawnattr_t attr; + struct sched_param schedparam; + printf("start ---- TestPosixSpawnattrGetschedparam\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPosixSpawnattrGetschedparam"), 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 --- TestPosixSpawnattrGetschedparam\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..c71e195f --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_getschedpolicy_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 "fuzzertest.h" + +void TestPosixSpawnattrGetschedpolicy(void) +{ + posix_spawnattr_t attr; + printf("start ---- TestPosixSpawnattrGetschedpolicy\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPosixSpawnattrGetschedpolicy"), 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], INITVALUE_S32); + posix_spawnattr_getschedpolicy((posix_spawnattr_t *)datainput, &policy); + } + DT_FUZZ_END(); + printf("end --- TestPosixSpawnattrGetschedpolicy\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..866527f4 --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_getsigdefault_fuzzer.cpp @@ -0,0 +1,50 @@ +/* + * 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 "fuzzertest.h" + +void TestPosixSpawnattrGetsigdefault(void) +{ + posix_spawnattr_t attr; + sigset_t signalset; + printf("start ---- TestPosixSpawnattrGetsigdefault\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPosixSpawnattrGetsigdefault"), 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 --- TestPosixSpawnattrGetsigdefault\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..4410762a --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_getsigmask_fuzzer.cpp @@ -0,0 +1,50 @@ +/* + * 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 "fuzzertest.h" + +void TestPosixSpawnattrGetsigmask(void) +{ + posix_spawnattr_t attr; + sigset_t signalset; + printf("start ---- TestPosixSpawnattrGetsigmask\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPosixSpawnattrGetsigmask"), 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 --- TestPosixSpawnattrGetsigmask\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..1bde6065 --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_init_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 +#include "fuzzertest.h" + +void TestPosixSpawnattrInit(void) +{ + posix_spawnattr_t attr; + printf("start ---- TestPosixSpawnattrInit\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPosixSpawnattrInit"), 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 --- TestPosixSpawnattrInit\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..92718e75 --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_setflags_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 "fuzzertest.h" + +void TestPosixSpawnattrSetflags(void) +{ + posix_spawnattr_t attr; + printf("start ---- TestPosixSpawnattrSetflags\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPosixSpawnattrSetflags"), 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], INITVALUE_S32); + posix_spawnattr_setflags((posix_spawnattr_t *)datainput, flags); + } + DT_FUZZ_END(); + printf("end --- TestPosixSpawnattrSetflags\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..6c11e0d7 --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_setpgroup_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 +#include "fuzzertest.h" + +void TestPosixSpawnattrSetpgroup(void) +{ + posix_spawnattr_t attr; + printf("start ---- TestPosixSpawnattrSetpgroup\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPosixSpawnattrSetpgroup"), 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], INITVALUE_S32); + posix_spawnattr_setpgroup((posix_spawnattr_t *)datainput, pgrp); + } + DT_FUZZ_END(); + printf("end --- TestPosixSpawnattrSetpgroup\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..5ddefaf6 --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_setschedparam_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 +#include +#include "fuzzertest.h" + +void TestPosixSpawnattrSetschedparam(void) +{ + posix_spawnattr_t attr; + struct sched_param schedparam; + printf("start ---- TestPosixSpawnattrSetschedparam\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPosixSpawnattrSetschedparam"), 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 --- TestPosixSpawnattrSetschedparam\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..85df5784 --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_setschedpolicy_fuzzer.cpp @@ -0,0 +1,50 @@ +/* + * 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 "fuzzertest.h" + +void TestPosixSpawnattrSetschedpolicy(void) +{ + posix_spawnattr_t attr; + printf("start ---- TestPosixSpawnattrSetschedpolicy\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPosixSpawnattrSetschedpolicy"), 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], INITVALUE_S32); + posix_spawnattr_setschedpolicy((posix_spawnattr_t *)datainput, policy); + } + DT_FUZZ_END(); + printf("end --- TestPosixSpawnattrSetschedpolicy\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..e9dd3e5f --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_setsigdefault_fuzzer.cpp @@ -0,0 +1,50 @@ +/* + * 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 "fuzzertest.h" + +void TestPosixSpawnattrSetsigdefault(void) +{ + posix_spawnattr_t attr; + sigset_t sigdefault; + printf("start ---- TestPosixSpawnattrSetsigdefault\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPosixSpawnattrSetsigdefault"), 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 --- TestPosixSpawnattrSetsigdefault\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..b26412e2 --- /dev/null +++ b/testsuites/fuzz/posix_spawnattr_setsigmask_fuzzer.cpp @@ -0,0 +1,50 @@ +/* + * 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 "fuzzertest.h" + +void TestPosixSpawnattrSetsigmask(void) +{ + posix_spawnattr_t attr; + sigset_t signalset; + printf("start ---- TestPosixSpawnattrSetsigmask\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPosixSpawnattrSetsigmask"), 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 --- TestPosixSpawnattrSetsigmask\n"); +} diff --git a/testsuites/fuzz/posix_spawnp_fuzzer.cpp b/testsuites/fuzz/posix_spawnp_fuzzer.cpp new file mode 100644 index 00000000..f2de4464 --- /dev/null +++ b/testsuites/fuzz/posix_spawnp_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 +#include +#include "fuzzertest.h" + +void TestPosixSpawnp(void) +{ + printf("start ---- TestPosixSpawnp\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPosixSpawnp"), 0) { + s32 pid = *(s32 *)DT_SetGetS32(&g_Element[0], INITVALUE_S32); + char *argv[] = {"tftp", nullptr}; + posix_spawnp(&pid, "/bin/tftp", nullptr, nullptr, argv, nullptr); + } + DT_FUZZ_END(); + printf("end --- TestPosixSpawnp\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..30854ae1 --- /dev/null +++ b/testsuites/fuzz/pthread_mutex_consistent_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 +#include "fuzzertest.h" + +void TestPthreadMutexConsistent(void) +{ + pthread_mutex_t fa; + printf("start----TestPthreadMutexConsistent\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPthreadMutexConsistent"), 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----TestPthreadMutexConsistent\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..d659eb0b --- /dev/null +++ b/testsuites/fuzz/pthread_mutex_getprioceiling_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 +#include "fuzzertest.h" + +void TestPthreadMutexGetprioceiling(void) +{ + pthread_mutex_t g_muxLock; + printf("start----TestPthreadMutexGetprioceiling\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPthreadMutexGetprioceiling"), 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], INITVALUE_S32); + 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----TestPthreadMutexGetprioceiling\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..1ce21c5f --- /dev/null +++ b/testsuites/fuzz/pthread_mutexattr_setprotocol_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 "fuzzertest.h" + +void TestPthreadMutexattrSetprotocol(void) +{ + pthread_mutexattr_t fa; + printf("start----TestPthreadMutexattrSetprotocol\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPthreadMutexattrSetprotocol"), 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], INITVALUE_S32); + pthread_mutexattr_setprotocol((pthread_mutexattr_t *)datainput, number); + } + DT_FUZZ_END() + printf("end----TestPthreadMutexattrSetprotocol\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..f1a7a155 --- /dev/null +++ b/testsuites/fuzz/pthread_mutexattr_setrobust_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 "fuzzertest.h" + +void TestPthreadMutexattrSetrobust(void) +{ + pthread_mutexattr_t fa; + printf("start----TestPthreadMutexattrSetrobust\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPthreadMutexattrSetrobust"), 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], INITVALUE_S32); + pthread_mutexattr_setrobust((pthread_mutexattr_t *)datainput, number); + } + DT_FUZZ_END() + printf("end----TestPthreadMutexattrSetrobust\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..7acbcbf0 --- /dev/null +++ b/testsuites/fuzz/pthread_mutexattr_settype_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 "fuzzertest.h" + +void TestPthreadMutexattrSettype(void) +{ + pthread_mutexattr_t fa; + printf("start----TestPthreadMutexattrSettype\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPthreadMutexattrSettype"), 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], INITVALUE_S32); + pthread_mutexattr_settype((pthread_mutexattr_t *)datainput, number); + } + DT_FUZZ_END() + printf("end----TestPthreadMutexattrSettype\n"); +} diff --git a/testsuites/fuzz/pthread_setconcurrency_fuzzer.cpp b/testsuites/fuzz/pthread_setconcurrency_fuzzer.cpp new file mode 100644 index 00000000..7cb46f09 --- /dev/null +++ b/testsuites/fuzz/pthread_setconcurrency_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 +#include "fuzzertest.h" + +void TestPthreadSetconcurrency(void) +{ + printf("start----TestPthreadSetconcurrency\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestPthreadSetconcurrency"), 0) { + s32 number = *(s32 *)DT_SetGetS32(&g_Element[0], INITVALUE_S32); + pthread_setconcurrency(number); + } + DT_FUZZ_END() + printf("end----TestPthreadSetconcurrency\n"); +} diff --git a/testsuites/fuzz/readlink_fuzzer.cpp b/testsuites/fuzz/readlink_fuzzer.cpp new file mode 100644 index 00000000..9280345a --- /dev/null +++ b/testsuites/fuzz/readlink_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 +#include "fuzzertest.h" + +void TestReadlink(void) +{ + printf("start----TestReadlink\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestReadlink"), 0) { + char *pathname = DT_SetGetBlob(&g_Element[0], LENGTH_STRING, MAXLENGTH_STRING, INITVALUE_STRING); + char *buf = DT_SetGetBlob(&g_Element[1], LENGTH_STRING, MAXLENGTH_STRING, INITVALUE_STRING); + int bufsize = DT_GET_MutatedValueLen(&g_Element[1]); + readlink(pathname, buf, bufsize); + } + DT_FUZZ_END() + printf("end----TestReadlink\n"); +} diff --git a/testsuites/fuzz/readlinkat_fuzzer.cpp b/testsuites/fuzz/readlinkat_fuzzer.cpp new file mode 100644 index 00000000..1f63f150 --- /dev/null +++ b/testsuites/fuzz/readlinkat_fuzzer.cpp @@ -0,0 +1,50 @@ +/* + * 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 "fuzzertest.h" + +void TestReadlinkat(void) +{ + printf("start----TestReadlinkat\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestReadlinkat"), 0) { + s32 dirfd = *(s32*)DT_SetGetS32(&g_Element[0], INITVALUE_S32); + char *pathname = DT_SetGetBlob(&g_Element[1], LENGTH_STRING, MAXLENGTH_STRING, INITVALUE_STRING); + char *buf = DT_SetGetBlob(&g_Element[2], LENGTH_STRING, MAXLENGTH_STRING, INITVALUE_STRING); + int bufsize = DT_GET_MutatedValueLen(&g_Element[2]); + readlinkat(dirfd, pathname, buf, bufsize); + } + DT_FUZZ_END() + printf("end----TestReadlinkat\n"); +} diff --git a/testsuites/fuzz/sem_open_fuzzer.cpp b/testsuites/fuzz/sem_open_fuzzer.cpp new file mode 100644 index 00000000..475f4a79 --- /dev/null +++ b/testsuites/fuzz/sem_open_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 +#include "sys/types.h" +#include "gtest/gtest.h" +#include "fuzzertest.h" + +void TestSemOpen(void) +{ + printf("start ---- TestSemOpen\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestSemOpen"), 0) { + char *buf = DT_SetGetString(&g_Element[0], LENGTH_STRING, MAXLENGTH_STRING, INITVALUE_STRING); + sem_open(buf, O_CREAT | O_EXCL, 0700, 1); + } + DT_FUZZ_END(); + printf("end --- TestSemOpen\n"); +} diff --git a/testsuites/fuzz/sethostname_fuzzer.cpp b/testsuites/fuzz/sethostname_fuzzer.cpp new file mode 100644 index 00000000..13cd4beb --- /dev/null +++ b/testsuites/fuzz/sethostname_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 "fuzzertest.h" + +void TestSethostname(void) +{ + printf("start----TestSethostname\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestSethostname"), 0) { + char *buf = DT_SetGetString(&g_Element[0], LENGTH_STRING, MAXLENGTH_STRING, INITVALUE_STRING); + s32 number = *(s32 *)DT_SetGetS32(&g_Element[1], INITVALUE_S32); + sethostname(buf, number); + } + DT_FUZZ_END() + printf("end----TestSethostname\n"); +} diff --git a/testsuites/fuzz/setns_fuzzer.cpp b/testsuites/fuzz/setns_fuzzer.cpp new file mode 100644 index 00000000..469122a5 --- /dev/null +++ b/testsuites/fuzz/setns_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 "fuzzertest.h" + +void TestSetns(void) +{ + printf("start----TestSetns\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestSetns"), 0) { + s32 number0 = *(s32 *)DT_SetGetS32(&g_Element[0], INITVALUE_S32); + s32 number1 = *(s32 *)DT_SetGetS32(&g_Element[1], INITVALUE_S32); + setns(number0, number1); + } + DT_FUZZ_END() + printf("end----TestSetns\n"); +} diff --git a/testsuites/fuzz/syslog_fuzzer.cpp b/testsuites/fuzz/syslog_fuzzer.cpp new file mode 100644 index 00000000..adf5166b --- /dev/null +++ b/testsuites/fuzz/syslog_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 "fuzzertest.h" + +void TestSyslog(void) +{ + printf("start----TestSyslog\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestSyslog"), 0) { + s32 number = *(s32 *)DT_SetGetS32(&g_Element[0], INITVALUE_S32); + char *buf = DT_SetGetString(&g_Element[1], LENGTH_STRING, MAXLENGTH_STRING, INITVALUE_STRING); + syslog(number, "%s\n", buf); + } + DT_FUZZ_END() + printf("end----TestSyslog\n"); +} diff --git a/testsuites/fuzz/system_fuzzer.cpp b/testsuites/fuzz/system_fuzzer.cpp new file mode 100644 index 00000000..1151fdfa --- /dev/null +++ b/testsuites/fuzz/system_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 +#include "fuzzertest.h" + +void TestSystem(void) +{ + printf("start----TestSystem\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestSystem"), 0) { + char *buf = DT_SetGetString(&g_Element[0], LENGTH_STRING, MAXLENGTH_STRING, INITVALUE_STRING); + system(buf); + } + DT_FUZZ_END() + printf("end----TestSystem\n"); +} diff --git a/testsuites/fuzz/times_fuzzer.cpp b/testsuites/fuzz/times_fuzzer.cpp new file mode 100644 index 00000000..449179b6 --- /dev/null +++ b/testsuites/fuzz/times_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 +#include +#include "fuzzertest.h" + +void TestTimes(void) +{ + struct tms buf; + printf("start----TestTimes\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestTimes"), 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----TestTimes\n"); +} diff --git a/testsuites/fuzz/unshare_fuzzer.cpp b/testsuites/fuzz/unshare_fuzzer.cpp new file mode 100644 index 00000000..8d451e4c --- /dev/null +++ b/testsuites/fuzz/unshare_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 +#include "fuzzertest.h" + +void TestUnshare(void) +{ + printf("start----TestUnshare\n"); + DT_Enable_Support_Loop(1); + + DT_FUZZ_START(0, FREQUENCY, const_cast("TestUnshare"), 0) { + s32 number = *(s32 *)DT_SetGetS32(&g_Element[0], INITVALUE_S32); + unshare(number); + } + DT_FUZZ_END() + printf("end----TestUnshare\n"); +} -- GitLab