1*e8763fb6SViktor Malik // SPDX-License-Identifier: GPL-2.0
2*e8763fb6SViktor Malik /* Copyright (C) 2025 Red Hat, Inc.*/
3*e8763fb6SViktor Malik #include "vmlinux.h"
4*e8763fb6SViktor Malik #include <bpf/bpf_helpers.h>
5*e8763fb6SViktor Malik #include <linux/limits.h>
6*e8763fb6SViktor Malik
7*e8763fb6SViktor Malik char long_str[XATTR_SIZE_MAX + 1];
8*e8763fb6SViktor Malik
test_strcmp_too_long(void * ctx)9*e8763fb6SViktor Malik SEC("syscall") int test_strcmp_too_long(void *ctx) { return bpf_strcmp(long_str, long_str); }
test_strchr_too_long(void * ctx)10*e8763fb6SViktor Malik SEC("syscall") int test_strchr_too_long(void *ctx) { return bpf_strchr(long_str, 'b'); }
test_strchrnul_too_long(void * ctx)11*e8763fb6SViktor Malik SEC("syscall") int test_strchrnul_too_long(void *ctx) { return bpf_strchrnul(long_str, 'b'); }
test_strnchr_too_long(void * ctx)12*e8763fb6SViktor Malik SEC("syscall") int test_strnchr_too_long(void *ctx) { return bpf_strnchr(long_str, sizeof(long_str), 'b'); }
test_strrchr_too_long(void * ctx)13*e8763fb6SViktor Malik SEC("syscall") int test_strrchr_too_long(void *ctx) { return bpf_strrchr(long_str, 'b'); }
test_strlen_too_long(void * ctx)14*e8763fb6SViktor Malik SEC("syscall") int test_strlen_too_long(void *ctx) { return bpf_strlen(long_str); }
test_strnlen_too_long(void * ctx)15*e8763fb6SViktor Malik SEC("syscall") int test_strnlen_too_long(void *ctx) { return bpf_strnlen(long_str, sizeof(long_str)); }
test_strspn_str_too_long(void * ctx)16*e8763fb6SViktor Malik SEC("syscall") int test_strspn_str_too_long(void *ctx) { return bpf_strspn(long_str, "a"); }
test_strspn_accept_too_long(void * ctx)17*e8763fb6SViktor Malik SEC("syscall") int test_strspn_accept_too_long(void *ctx) { return bpf_strspn("b", long_str); }
test_strcspn_str_too_long(void * ctx)18*e8763fb6SViktor Malik SEC("syscall") int test_strcspn_str_too_long(void *ctx) { return bpf_strcspn(long_str, "b"); }
test_strcspn_reject_too_long(void * ctx)19*e8763fb6SViktor Malik SEC("syscall") int test_strcspn_reject_too_long(void *ctx) { return bpf_strcspn("b", long_str); }
test_strstr_too_long(void * ctx)20*e8763fb6SViktor Malik SEC("syscall") int test_strstr_too_long(void *ctx) { return bpf_strstr(long_str, "hello"); }
test_strnstr_too_long(void * ctx)21*e8763fb6SViktor Malik SEC("syscall") int test_strnstr_too_long(void *ctx) { return bpf_strnstr(long_str, "hello", sizeof(long_str)); }
22*e8763fb6SViktor Malik
23*e8763fb6SViktor Malik char _license[] SEC("license") = "GPL";
24