From eb31c52026f12cb23d5abc0bf5d0590ea5f418bf Mon Sep 17 00:00:00 2001 From: Christophe Grenier Date: Sun, 11 Oct 2015 10:27:59 +0200 Subject: [PATCH] PhotoRec: replace single-quote by underscore char when renaming files --- src/filegen.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/filegen.c b/src/filegen.c index ffde54fb..6076f1f8 100644 --- a/src/filegen.c +++ b/src/filegen.c @@ -358,7 +358,7 @@ file_stat_t * init_file_stats(file_enable_t *files_enable) } /* The original filename begins at offset in buffer and is null terminated */ -int file_rename(file_recovery_t *file_recovery, const void *buffer, const int buffer_size, const int offset, const char *new_ext, const int force_ext) +int file_rename(file_recovery_t *file_recovery, const void *buffer, const int buffer_size, const int offset, const char *new_ext, const int append_original_ext) { /* new_filename is large enough to avoid a buffer overflow */ char *new_filename; @@ -412,6 +412,7 @@ int file_rename(file_recovery_t *file_recovery, const void *buffer, const int bu case '<': case '>': case '|': + case '\'': if(*(dst-1) != '_') *dst++ = '_'; bad++; @@ -447,7 +448,7 @@ int file_rename(file_recovery_t *file_recovery, const void *buffer, const int bu while(*src!='\0') *dst++ = *src++; } - else if(force_ext>0) + else if(append_original_ext>0) { if(ext!=NULL) { @@ -463,7 +464,7 @@ int file_rename(file_recovery_t *file_recovery, const void *buffer, const int bu if(buffer==NULL) return -1; /* Try without the original filename */ - return file_rename(file_recovery, NULL, 0, 0, new_ext, force_ext); + return file_rename(file_recovery, NULL, 0, 0, new_ext, append_original_ext); } if(strlen(new_filename)filename)) { @@ -474,7 +475,7 @@ int file_rename(file_recovery_t *file_recovery, const void *buffer, const int bu } /* The original filename begins at offset in buffer and is null terminated */ -int file_rename_unicode(file_recovery_t *file_recovery, const void *buffer, const int buffer_size, const int offset, const char *new_ext, const int force_ext) +int file_rename_unicode(file_recovery_t *file_recovery, const void *buffer, const int buffer_size, const int offset, const char *new_ext, const int append_original_ext) { /* new_filename is large enough to avoid a buffer overflow */ char *new_filename; @@ -555,7 +556,7 @@ int file_rename_unicode(file_recovery_t *file_recovery, const void *buffer, cons while(*src!='\0') *dst++ = *src++; } - else if(force_ext>0) + else if(append_original_ext>0) { while(*ext!='\0') *dst++ = *ext++; @@ -568,7 +569,7 @@ int file_rename_unicode(file_recovery_t *file_recovery, const void *buffer, cons if(buffer==NULL) return -1; /* Try without the original filename */ - return file_rename_unicode(file_recovery, NULL, 0, 0, new_ext, force_ext); + return file_rename_unicode(file_recovery, NULL, 0, 0, new_ext, append_original_ext); } if(strlen(new_filename)filename)) {