git-svn: trunk@1716
Tomasz Kojm authored on 2005/09/15 21:05:30... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Thu Sep 15 14:03:15 CEST 2005 (tk) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav/mspack/mszipd.c: zipd_read_input: fake one more byte if input |
|
4 |
+ stream gets overrun |
|
5 |
+ |
|
1 | 6 |
Mon Sep 5 18:18:24 CEST 2005 (tk) |
2 | 7 |
---------------------------------- |
3 | 8 |
* libclamav/matcher.c: handle EP-n offset specification (requested by |
... | ... |
@@ -48,7 +48,7 @@ struct mszipd_stream { |
48 | 48 |
/* inflate() will call this whenever the window should be emptied. */ |
49 | 49 |
int (*flush_window)(struct mszipd_stream *, unsigned int); |
50 | 50 |
|
51 |
- int error, repair_mode, bytes_output; |
|
51 |
+ int error, repair_mode, bytes_output, input_end; |
|
52 | 52 |
|
53 | 53 |
/* I/O buffering */ |
54 | 54 |
unsigned char *inbuf, *i_ptr, *i_end, *o_ptr, *o_end; |
... | ... |
@@ -95,7 +95,20 @@ static const unsigned short bit_mask[17] = { |
95 | 95 |
|
96 | 96 |
static int zipd_read_input(struct mszipd_stream *zip) { |
97 | 97 |
int read = zip->sys->read(zip->input, &zip->inbuf[0], (int)zip->inbuf_size); |
98 |
- if (read <= 0) return zip->error = MSPACK_ERR_READ; |
|
98 |
+ if (read < 0) return zip->error = MSPACK_ERR_READ; |
|
99 |
+ |
|
100 |
+ if (read == 0) { |
|
101 |
+ if (zip->input_end) { |
|
102 |
+ D(("out of input bytes")) |
|
103 |
+ return zip->error = MSPACK_ERR_READ; |
|
104 |
+ } |
|
105 |
+ else { |
|
106 |
+ read = 1; |
|
107 |
+ zip->inbuf[0] = 0; |
|
108 |
+ zip->input_end = 1; |
|
109 |
+ } |
|
110 |
+ } |
|
111 |
+ |
|
99 | 112 |
zip->i_ptr = &zip->inbuf[0]; |
100 | 113 |
zip->i_end = &zip->inbuf[read]; |
101 | 114 |
|
... | ... |
@@ -554,6 +567,7 @@ struct mszipd_stream *mszipd_init(struct mspack_system *system, |
554 | 554 |
zip->error = MSPACK_ERR_OK; |
555 | 555 |
zip->repair_mode = repair_mode; |
556 | 556 |
zip->flush_window = &mszipd_flush_window; |
557 |
+ zip->input_end = 0; |
|
557 | 558 |
|
558 | 559 |
zip->i_ptr = zip->i_end = &zip->inbuf[0]; |
559 | 560 |
zip->o_ptr = zip->o_end = NULL; |