Browse code

libclamav/matcher-bm.c: properly handle scan boundaries in offset mode (bb#1840)

Tomasz Kojm authored on 2010/03/06 05:14:55
Showing 2 changed files
... ...
@@ -1,3 +1,8 @@
1
+Fri Mar  5 21:14:12 CET 2010 (tk)
2
+---------------------------------
3
+ * libclamav/matcher-bm.c: properly handle scan boundaries in
4
+			   offset mode (bb#1840)
5
+
1 6
 Fri Mar  5 19:11:25 CET 2010 (tk)
2 7
 ---------------------------------
3 8
  * libclamav: fix cl_cvdparse() leak (bb#1859)
... ...
@@ -269,7 +269,10 @@ int cli_bm_scanbuff(const unsigned char *buffer, uint32_t length, const char **v
269 269
     memset(&info, 0, sizeof(info));
270 270
     i = BM_MIN_LENGTH - BM_BLOCK_SIZE;
271 271
     if(offdata) {
272
-	if(offdata->pos == offdata->cnt)
272
+	for(; offdata->pos && offdata->offtab[offdata->pos] > offset; offdata->pos--);
273
+	if(offdata->offtab[offdata->pos] < offset)
274
+	    offdata->pos++;
275
+	if(offdata->pos >= offdata->cnt)
273 276
 	    return CL_CLEAN;
274 277
 	i += offdata->offtab[offdata->pos] - offset;
275 278
     }