Check length of AOF file name in redis-check-aof (CVE-2025-27151)

Ensure that the length of the input file name does not exceed PATH_MAX
This commit is contained in:
YaacovHazan 2025-05-27 10:23:27 +03:00 committed by YaacovHazan
parent 35eff3d49a
commit d0eeee6e31
1 changed files with 6 additions and 0 deletions

View File

@ -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);