git-svn: trunk@2758
aCaB authored on 2007/02/18 04:19:06... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Sat Feb 17 02:34:17 CET 2007 (acab) |
|
2 |
+----------------------------------- |
|
3 |
+ * libclamav/rtf.c: Don't spin on on cli_readn (bb#312) - patch from Edvin |
|
4 |
+ |
|
1 | 5 |
Sat Feb 17 01:31:45 CET 2007 (acab) |
2 | 6 |
----------------------------------- |
3 | 7 |
* libclamav/regex_list.c: Close #303 - patch from Edvin |
... | ... |
@@ -73,6 +73,7 @@ struct stack { |
73 | 73 |
size_t elements; |
74 | 74 |
size_t stack_cnt; |
75 | 75 |
size_t stack_size; |
76 |
+ int warned; |
|
76 | 77 |
}; |
77 | 78 |
|
78 | 79 |
static const struct rtf_action_mapping { |
... | ... |
@@ -188,7 +189,10 @@ static int pop_state(struct stack* stack,struct rtf_state* state) |
188 | 188 |
return 0;/* this is a default 'state'*/ |
189 | 189 |
} |
190 | 190 |
if(!stack->stack_cnt) { |
191 |
+ if(!stack->warned) { |
|
191 | 192 |
cli_dbgmsg("Warning: attempt to pop from empty stack!\n"); |
193 |
+ stack->warned = 1; |
|
194 |
+ } |
|
192 | 195 |
*state = base_state;/* lets assume we give it a base state */ |
193 | 196 |
return 0; |
194 | 197 |
} |
... | ... |
@@ -504,7 +508,7 @@ int cli_scanrtf(int desc, cli_ctx *ctx) |
504 | 504 |
int ret = CL_CLEAN; |
505 | 505 |
struct rtf_state state; |
506 | 506 |
struct stack stack; |
507 |
- size_t bread; |
|
507 |
+ ssize_t bread; |
|
508 | 508 |
table_t* actiontable; |
509 | 509 |
uint8_t main_symbols[256]; |
510 | 510 |
|
... | ... |
@@ -518,6 +522,7 @@ int cli_scanrtf(int desc, cli_ctx *ctx) |
518 | 518 |
stack.stack_cnt = 0; |
519 | 519 |
stack.stack_size = 16; |
520 | 520 |
stack.elements = 0; |
521 |
+ stack.warned = 0; |
|
521 | 522 |
stack.states = cli_malloc(stack.stack_size*sizeof(*stack.states)); |
522 | 523 |
|
523 | 524 |
if(!stack.states) |
... | ... |
@@ -553,7 +558,7 @@ int cli_scanrtf(int desc, cli_ctx *ctx) |
553 | 553 |
|
554 | 554 |
init_rtf_state(&state); |
555 | 555 |
|
556 |
- while(( bread = cli_readn(desc, buff, BUFF_SIZE) )) { |
|
556 |
+ while(( bread = cli_readn(desc, buff, BUFF_SIZE) ) > 0) { |
|
557 | 557 |
ptr = buff; |
558 | 558 |
ptr_end = buff + bread; |
559 | 559 |
while(ptr < ptr_end) { |