diff options
author | chenyang8094 <chenyang8094@users.noreply.github.com> | 2022-02-22 16:09:34 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-22 10:09:34 +0200 |
commit | 4916d79fbdbfdb4819f11a6c2c22a7b576e1c6e7 (patch) | |
tree | 71e46660582398d7845ddcc053a6afc2c85322d7 /src/redis-check-aof.c | |
parent | 65e4bce0e79b09a1666753889c0ca4038c235e43 (diff) | |
download | redis-4916d79fbdbfdb4819f11a6c2c22a7b576e1c6e7.tar.gz |
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.
Diffstat (limited to 'src/redis-check-aof.c')
-rw-r--r-- | src/redis-check-aof.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/redis-check-aof.c b/src/redis-check-aof.c index d2ff21068..a3da79dd4 100644 --- a/src/redis-check-aof.c +++ b/src/redis-check-aof.c @@ -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. */ |