From 54897586fd7fb4a103c6a5af2486232df8c2ba84 Mon Sep 17 00:00:00 2001 From: Christophe Grenier Date: Sat, 17 Sep 2011 17:08:03 +0200 Subject: [PATCH] PhotoRec: when renaming file, filter out name with too much bad chars --- src/filegen.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/filegen.c b/src/filegen.c index 8b01cc67..6f95dd33 100644 --- a/src/filegen.c +++ b/src/filegen.c @@ -382,7 +382,10 @@ void file_rename(const char *old_filename, const unsigned char *buffer, const in /* Add original filename */ if(offset < buffer_size && buffer!=NULL) { + char *dst_old=dst; int off; + int ok=0; + int bad=0; *dst++ = '_'; for(off=offset; off dst_old && *(dst-1)=='_') + dst--; + } } /* Add extension */ if(new_ext!=NULL) @@ -458,7 +475,10 @@ void file_rename_unicode(const char *old_filename, const unsigned char *buffer, /* Add original filename */ if(offset < buffer_size && buffer!=NULL) { + char *dst_old=dst; int off; + int ok=0; + int bad=0; *dst++ = '_'; for(off=offset; off dst_old && *(dst-1)=='_') + dst--; + } } /* Add extension */ if(new_ext!=NULL)