Browse code

fix possible crash in cli_bitset_test()

git-svn: trunk@1887

Trog authored on 2006/04/05 17:07:53
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Wed Apr  5 09:06:48 BST 2006 (trog)
2
+-----------------------------------
3
+  * libclamav/others.c: fix possible crash in cli_bitset_test()
4
+
1 5
 Wed Apr  5 01:13:22 CEST 2006 (tk)
2 6
 ----------------------------------
3 7
   * libclamav/scanners.c: don't return type values in cli_scanraw()
... ...
@@ -756,6 +756,9 @@ int cli_bitset_test(bitset_t *bs, unsigned long bit_offset)
756 756
 	
757 757
 	char_offset = bit_offset / BITS_PER_CHAR;
758 758
 	bit_offset = bit_offset % BITS_PER_CHAR;
759
-	
759
+
760
+	if (char_offset >= bs->length) {	
761
+		return FALSE;
762
+	}
760 763
 	return (bs->bitset[char_offset] & ((unsigned char)1 << bit_offset));
761 764
 }