diff --git a/src/redis-check-aof.c b/src/redis-check-aof.c index e28126df6..5b3ee2a48 100644 --- a/src/redis-check-aof.c +++ b/src/redis-check-aof.c @@ -547,6 +547,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);