Unverified Commit 4916d79f authored by chenyang8094's avatar chenyang8094 Committed by GitHub
Browse files

Fix path copy error and add more logs. (#10324)

Since we didn't copy the null terminator to temp_filepath, dirname could return the wrong result.
parent 65e4bce0
......@@ -226,7 +226,7 @@ int checkSingleAof(char *aof_filename, char *aof_filepath, int last_file, int fi
FILE *fp = fopen(aof_filepath, "r+");
if (fp == NULL) {
printf("Cannot open file: %s, aborting...\n", aof_filename);
printf("Cannot open file %s: %s, aborting...\n", aof_filepath, strerror(errno));
exit(1);
}
......@@ -336,7 +336,7 @@ int checkSingleAof(char *aof_filename, char *aof_filepath, int last_file, int fi
int fileIsRDB(char *filepath) {
FILE *fp = fopen(filepath, "r");
if (fp == NULL) {
printf("Cannot open file: %s\n", filepath);
printf("Cannot open file %s: %s\n", filepath, strerror(errno));
exit(1);
}
......@@ -372,7 +372,7 @@ int fileIsManifest(char *filepath) {
int is_manifest = 0;
FILE *fp = fopen(filepath, "r");
if (fp == NULL) {
printf("Cannot open file: %s\n", filepath);
printf("Cannot open file %s: %s\n", filepath, strerror(errno));
exit(1);
}
......@@ -554,7 +554,7 @@ int redis_check_aof_main(int argc, char **argv) {
}
/* In the glibc implementation dirname may modify their argument. */
memcpy(temp_filepath, filepath, strlen(filepath));
memcpy(temp_filepath, filepath, strlen(filepath) + 1);
dirpath = dirname(temp_filepath);
/* Select the corresponding verification method according to the input file type. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment