summaryrefslogtreecommitdiffstats
path: root/src/file_zip.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/file_zip.c')
-rw-r--r--src/file_zip.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/file_zip.c b/src/file_zip.c
index 68f2431..a9dfe92 100644
--- a/src/file_zip.c
+++ b/src/file_zip.c
@@ -880,7 +880,9 @@ static int header_check_winzip(const unsigned char *buffer, const unsigned int b
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;