From b09c6d56832eb1718c07d74abf3bc6ae3fe4e030 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:36:04 +0200 Subject: Adding upstream version 1.1.0. Signed-off-by: Daniel Baumann --- .../go-redis/redis/v8@v8.11.5/fuzz/fuzz.go | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 dependencies/pkg/mod/github.com/go-redis/redis/v8@v8.11.5/fuzz/fuzz.go (limited to 'dependencies/pkg/mod/github.com/go-redis/redis/v8@v8.11.5/fuzz/fuzz.go') diff --git a/dependencies/pkg/mod/github.com/go-redis/redis/v8@v8.11.5/fuzz/fuzz.go b/dependencies/pkg/mod/github.com/go-redis/redis/v8@v8.11.5/fuzz/fuzz.go new file mode 100644 index 0000000..3225d24 --- /dev/null +++ b/dependencies/pkg/mod/github.com/go-redis/redis/v8@v8.11.5/fuzz/fuzz.go @@ -0,0 +1,49 @@ +//go:build gofuzz +// +build gofuzz + +package fuzz + +import ( + "context" + "time" + + "github.com/go-redis/redis/v8" +) + +var ( + ctx = context.Background() + rdb *redis.Client +) + +func init() { + rdb = redis.NewClient(&redis.Options{ + Addr: ":6379", + DialTimeout: 10 * time.Second, + ReadTimeout: 10 * time.Second, + WriteTimeout: 10 * time.Second, + PoolSize: 10, + PoolTimeout: 10 * time.Second, + }) +} + +func Fuzz(data []byte) int { + arrayLen := len(data) + if arrayLen < 4 { + return -1 + } + maxIter := int(uint(data[0])) + for i := 0; i < maxIter && i < arrayLen; i++ { + n := i % arrayLen + if n == 0 { + _ = rdb.Set(ctx, string(data[i:]), string(data[i:]), 0).Err() + } else if n == 1 { + _, _ = rdb.Get(ctx, string(data[i:])).Result() + } else if n == 2 { + _, _ = rdb.Incr(ctx, string(data[i:])).Result() + } else if n == 3 { + var cursor uint64 + _, _, _ = rdb.Scan(ctx, cursor, string(data[i:]), 10).Result() + } + } + return 1 +} -- cgit v1.2.3