summaryrefslogtreecommitdiffstats
path: root/src/file_mp3.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2018-02-18 09:58:02 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2018-02-18 09:58:02 +0100
commitfe2059efa9959386b7ad2e1d5a72154800242a97 (patch)
tree7ff5e3f74460497108ce2a00682c40ebec0365e4 /src/file_mp3.c
parente0d2dc2f39b3cec37308b470d872974afd0e54b2 (diff)
PhotoRec: fix bound check when parsing exe, fits, jpg, mp3, riff, zip
Diffstat (limited to 'src/file_mp3.c')
-rw-r--r--src/file_mp3.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/file_mp3.c b/src/file_mp3.c
index cddcbb0..9cde947 100644
--- a/src/file_mp3.c
+++ b/src/file_mp3.c
@@ -367,7 +367,9 @@ static data_check_t data_check_mp3(const unsigned char *buffer, const unsigned i
static unsigned int pos_in_mem(const unsigned char *haystack, const unsigned int haystack_size, const unsigned char *needle, const unsigned int needle_size)
{
unsigned int i;
- for(i=0;i<haystack_size;i++)
+ if(haystack_size < needle_size)
+ return 0;
+ for(i=0; i <= haystack_size - needle_size; i++)
if(memcmp(&haystack[i],needle,needle_size)==0)
return (i+needle_size);
return 0;