valkey/valkey-cve-2025-27151.patch

35 lines
1.1 KiB
Diff

From 73696bf6e2cf754acc3ec24eaf9ca6b879bfc5d7 Mon Sep 17 00:00:00 2001
From: Madelyn Olson <madelyneolson@gmail.com>
Date: Thu, 29 May 2025 00:06:23 +0100
Subject: [PATCH] Incorporate Redis CVE for CVE-2025-27151 (#2146)
Resolves https://github.com/valkey-io/valkey/issues/2145
Incorporate the CVE patch that was sent to us by Redis Ltd.
---------
Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Co-authored-by: Ping Xie <pingxie@outlook.com>
---
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..a6e4b97c6d 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 (strnlen(filepath, PATH_MAX + 1) > 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);