diff --git a/testsuites/BUILD.gn b/testsuites/BUILD.gn index c09cb41cb9ba3546c4507ab83309511366282e75..d6e02339c10352cecea8c53b1c5eee6cdb3635cc 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 0000000000000000000000000000000000000000..2d8bccbe86eaaf7bdc22d9756851773feaf3467e --- /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 0000000000000000000000000000000000000000..294a91d74486ab27643b43b46c680238db31fc6e --- /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 0000000000000000000000000000000000000000..4db53e364285427e88e234a6d234971b7ebd5493 --- /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 0000000000000000000000000000000000000000..2ac95f6b9601f0d6653809005704a84cd0ff9b30 --- /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 0000000000000000000000000000000000000000..9a143a90ae5ef625080be9a209d106580c02a162 --- /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 0000000000000000000000000000000000000000..1312df5d05c4b9071cccb84a66d0c73df210dafb --- /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 0000000000000000000000000000000000000000..1bdb16f7d2134806089fb245298b939861070f83 --- /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 0000000000000000000000000000000000000000..7df967079d96ec75f75e789b492684b3ef64385d --- /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 0000000000000000000000000000000000000000..559b452b123708316adf444b7d28c986fdc44cd5 --- /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 0000000000000000000000000000000000000000..20af512647895e6acebcacf006cd7a45819f7b20 --- /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 0000000000000000000000000000000000000000..83b7b7586157e6367c2f52c7226f47c86d116860 --- /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 0000000000000000000000000000000000000000..06169988bfbf536788666fb3b409867c3132efb6 --- /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 0000000000000000000000000000000000000000..c9c35f45add3e555823e2faa8527968d346f908e --- /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 0000000000000000000000000000000000000000..bef1a86504680e5a3675c0b44d02a4428fbcff0e --- /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 0000000000000000000000000000000000000000..d7b877eb60a8409384829ba34eb674a3e889bd40 --- /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 0000000000000000000000000000000000000000..894e6283905e84b583ff56d17af20c2a689eb3c2 --- /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 0000000000000000000000000000000000000000..5310b781b4869ab18ad964a019997f7910dc971b --- /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 0000000000000000000000000000000000000000..1acd5089cca454aefef83f9af425a050322dc64f --- /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 0000000000000000000000000000000000000000..d62edb054ac92e535b140f3d072df52adc1a210d --- /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 0000000000000000000000000000000000000000..202856470f47815de8958bfa202ff42a17cfc6f2 --- /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 0000000000000000000000000000000000000000..c9da6ad1d26505bee43eec33d5c2b62cacec85ef --- /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 0000000000000000000000000000000000000000..ed299f6320c1bbf9d7e7d18117ea21ba847b93c5 --- /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 0000000000000000000000000000000000000000..12e92060818c485937acd31871b9b5628f4693f3 --- /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 0000000000000000000000000000000000000000..90b0b06bf6354f866c4750c3474db88b5d7244f5 --- /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 0000000000000000000000000000000000000000..c71e195fbf0d723ceee4c3e262d4ced4ace2910e --- /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 0000000000000000000000000000000000000000..866527f417230e98497bc95e42412cd5e53705de --- /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 0000000000000000000000000000000000000000..4410762a559546211d72972283cbfe012d31c15f --- /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 0000000000000000000000000000000000000000..1bde6065e1795b5ce33711e52291bfe71a17f99a --- /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 0000000000000000000000000000000000000000..92718e75d7050b10f665a9b059b1485c95651c39 --- /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 0000000000000000000000000000000000000000..6c11e0d7f4f3955c09e91f03dd9ce99dc373015a --- /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 0000000000000000000000000000000000000000..5ddefaf6ca7fb68d384989e3eae70cc11d30e7d1 --- /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 0000000000000000000000000000000000000000..85df5784d15510d3beb7a42a226780971d2a02f5 --- /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 0000000000000000000000000000000000000000..e9dd3e5f481729a55eee09f7f74f74b22968bdb6 --- /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 0000000000000000000000000000000000000000..b26412e2fd563a98624240e86be3af05b3a2d961 --- /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 0000000000000000000000000000000000000000..f2de44641216d5bc2a3f293c5be311027033160d --- /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 0000000000000000000000000000000000000000..30854ae12c58b01625f9c212959ff2b338a31413 --- /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 0000000000000000000000000000000000000000..d659eb0becd928348d0bbc4050627b20965d58ad --- /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 0000000000000000000000000000000000000000..1ce21c5f06b5177c362facc93e61e65def59e036 --- /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 0000000000000000000000000000000000000000..f1a7a1557b3beb9407b44edf69d2d5ef91074850 --- /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 0000000000000000000000000000000000000000..7acbcbf00b101a2df79f0bc2029dda8dd780b243 --- /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 0000000000000000000000000000000000000000..7cb46f099c14e16496bbcbfb4bf7b18ce7aecf11 --- /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 0000000000000000000000000000000000000000..9280345a8641072bcb36ae82aaa3a90391a64abc --- /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 0000000000000000000000000000000000000000..1f63f150231fe11c5518f6675b7b525ab2a16a83 --- /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 0000000000000000000000000000000000000000..475f4a7982cbdd7893a5659cd344fd51842deea5 --- /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 0000000000000000000000000000000000000000..13cd4beb9449f8a4485c0a59446af6d3e39d4972 --- /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 0000000000000000000000000000000000000000..469122a5f445e4a4dbd0ff2829325fb15e29fe82 --- /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 0000000000000000000000000000000000000000..adf5166b271f7fe3f1cc6f1e797bbd85bf547752 --- /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 0000000000000000000000000000000000000000..1151fdfaa1fdec0a8cb9f8d7a644fc2c754a00c8 --- /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 0000000000000000000000000000000000000000..449179b6db11ad80574d5824444061ac2a60f420 --- /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 0000000000000000000000000000000000000000..8d451e4c3e6144cb3c43b228e275104c318e0506 --- /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"); +}