summaryrefslogtreecommitdiffstats
path: root/src/filegen.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2015-10-11 10:27:59 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2015-10-11 10:27:59 +0200
commiteb31c52026f12cb23d5abc0bf5d0590ea5f418bf (patch)
treed84528facc7beaf69c53fcd9e4b0960dd9e492a4 /src/filegen.c
parent82ae16950233a3d00cec78c3dbce84a3b10eef32 (diff)
PhotoRec: replace single-quote by underscore char when renaming files
Diffstat (limited to 'src/filegen.c')
-rw-r--r--src/filegen.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/filegen.c b/src/filegen.c
index ffde54f..6076f1f 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)<sizeof(file_recovery->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)<sizeof(file_recovery->filename))
{