summaryrefslogtreecommitdiffstats
path: root/src/file_ps.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2010-05-21 09:07:09 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2010-05-21 09:07:09 +0200
commit3d9a968bdd867236e6e7a2df6384678b97b85a37 (patch)
treedf306644f940f82181fa45349e4d85402e2d1085 /src/file_ps.c
parentbfbc6e6e3378889cabcca964064f9bda802afc75 (diff)
PhotoRec: .ps file recovery - handle very small buffersize
Diffstat (limited to 'src/file_ps.c')
-rw-r--r--src/file_ps.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/file_ps.c b/src/file_ps.c
index c3250a0..91d84fe 100644
--- a/src/file_ps.c
+++ b/src/file_ps.c
@@ -90,12 +90,15 @@ static int header_check_ps(const unsigned char *buffer, const unsigned int buffe
static int data_check_ps(const unsigned char *buffer, const unsigned int buffer_size, file_recovery_t *file_recovery)
{
unsigned int i;
- for(i=(buffer_size/2)-4;i+4<buffer_size;i++)
+ if(buffer_size>8)
{
- if(buffer[i]=='%' && buffer[i+1]=='%' && buffer[i+2]=='E' && buffer[i+3]=='O' && buffer[i+4]=='F')
+ for(i=(buffer_size/2)-4;i+4<buffer_size;i++)
{
- file_recovery->calculated_file_size=file_recovery->file_size+i+5-(buffer_size/2);
- return 2;
+ if(buffer[i]=='%' && buffer[i+1]=='%' && buffer[i+2]=='E' && buffer[i+3]=='O' && buffer[i+4]=='F')
+ {
+ file_recovery->calculated_file_size=file_recovery->file_size+i+5-(buffer_size/2);
+ return 2;
+ }
}
}
file_recovery->calculated_file_size=file_recovery->file_size+(buffer_size/2);