From 7f04aa674fa151382794004c66b9f25732913d2e Mon Sep 17 00:00:00 2001 From: Madelyn Olson Date: Wed, 28 May 2025 10:31:13 -0700 Subject: [PATCH 1/2] Apply cherry-pick of CVE provided by Redis Signed-off-by: Madelyn Olson --- src/valkey-check-aof.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/valkey-check-aof.c b/src/valkey-check-aof.c index ed0eb2b49d..bacdaabea8 100644 --- a/src/valkey-check-aof.c +++ b/src/valkey-check-aof.c @@ -556,6 +556,12 @@ int redis_check_aof_main(int argc, char **argv) { goto invalid_args; } + /* Check if filepath is longer than PATH_MAX */ + if (strlen(filepath) > PATH_MAX) { + printf("Error: filepath is too long (exceeds PATH_MAX)\n"); + goto invalid_args; + } + /* In the glibc implementation dirname may modify their argument. */ memcpy(temp_filepath, filepath, strlen(filepath) + 1); dirpath = dirname(temp_filepath); From 7a95027408ebf6d46881015b68eb661c447e724c Mon Sep 17 00:00:00 2001 From: Madelyn Olson Date: Wed, 28 May 2025 10:53:17 -0700 Subject: [PATCH 2/2] Update src/valkey-check-aof.c Co-authored-by: Ping Xie Signed-off-by: Madelyn Olson --- src/valkey-check-aof.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/valkey-check-aof.c b/src/valkey-check-aof.c index bacdaabea8..a6e4b97c6d 100644 --- a/src/valkey-check-aof.c +++ b/src/valkey-check-aof.c @@ -557,7 +557,7 @@ int redis_check_aof_main(int argc, char **argv) { } /* Check if filepath is longer than PATH_MAX */ - if (strlen(filepath) > PATH_MAX) { + if (strnlen(filepath, PATH_MAX + 1) > PATH_MAX) { printf("Error: filepath is too long (exceeds PATH_MAX)\n"); goto invalid_args; }