Browse code

fix off-by-one error in hex decoder (bb#190)

git-svn: trunk@2548

Tomasz Kojm authored on 2006/12/10 00:40:30
Showing 2 changed files
... ...
@@ -1,3 +1,8 @@
1
+Sat Dec  9 16:37:18 CET 2006 (tk)
2
+---------------------------------
3
+  * libclamav/rtf.c: fix off-by-one error in hex decoder (bb#190),
4
+		     patch from Edvin
5
+
1 6
 Sat Dec  9 08:36:20 GMT 2006 (njh)
2 7
 ----------------------------------
3 8
   * libclamav/pst.c:		Fix typo in the recent patches
... ...
@@ -267,11 +267,19 @@ static int rtf_object_process(struct rtf_state* state, const unsigned char* inpu
267 267
 		return 0;
268 268
 
269 269
 	if(data->has_partial) {
270
-		outdata[out_cnt++] = data->partial | input[0];
270
+		for(i=0;i<len && !isxdigit(input[i]);i++)
271
+			;
272
+		if(i<len) {
273
+			outdata[out_cnt++] = data->partial | hextable[input[i++]];
274
+			data->has_partial = 0;
275
+		}
276
+		else
277
+			return 0;
271 278
 	}
279
+	else
280
+		i = 0;
272 281
 
273
-	data->has_partial = 0;
274
-	for(i=0;i<len;i++) {
282
+	for(;i<len;i++) {
275 283
 		if(isxdigit(input[i])) {
276 284
 				const unsigned char byte = hextable[ input[i++] ] << 4;
277 285
 				while(i<len && !isxdigit(input[i]))