git-svn: trunk@1663
Nigel Horne authored on 2005/07/23 07:16:21... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Fri Jul 22 23:15:20 BST 2005 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav/pdf.c: Remove allocation of 0 bytes if ascii85decode decodes |
|
4 |
+ to 0 bytes |
|
5 |
+ |
|
1 | 6 |
Thu Jul 21 03:47:03 CEST 2005 (tk) |
2 | 7 |
---------------------------------- |
3 | 8 |
* libclamav/others.c: cli_rmdirs: fix possible infinite loop. Patch by Mark |
... | ... |
@@ -15,7 +15,7 @@ |
15 | 15 |
* along with this program; if not, write to the Free Software |
16 | 16 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
17 | 17 |
*/ |
18 |
-static char const rcsid[] = "$Id: pdf.c,v 1.27 2005/06/24 20:48:53 nigelhorne Exp $"; |
|
18 |
+static char const rcsid[] = "$Id: pdf.c,v 1.28 2005/07/22 22:15:08 nigelhorne Exp $"; |
|
19 | 19 |
|
20 | 20 |
#if HAVE_CONFIG_H |
21 | 21 |
#include "clamav-config.h" |
... | ... |
@@ -227,6 +227,13 @@ cli_pdf(const char *dir, int desc) |
227 | 227 |
break; |
228 | 228 |
} |
229 | 229 |
} |
230 |
+ streamlen = (int)(streamend - streamstart) + 1; |
|
231 |
+ |
|
232 |
+ if(streamlen == 0) { |
|
233 |
+ cli_dbgmsg("Empty stream"); |
|
234 |
+ continue; |
|
235 |
+ } |
|
236 |
+ |
|
230 | 237 |
/*while(strchr("\r\n", *--streamend)) |
231 | 238 |
;*/ |
232 | 239 |
snprintf(fullname, sizeof(fullname), "%s/pdfXXXXXX", dir); |
... | ... |
@@ -243,8 +250,6 @@ cli_pdf(const char *dir, int desc) |
243 | 243 |
break; |
244 | 244 |
} |
245 | 245 |
|
246 |
- streamlen = (int)(streamend - streamstart) + 1; |
|
247 |
- |
|
248 | 246 |
cli_dbgmsg("length %d, streamlen %d\n", length, streamlen); |
249 | 247 |
|
250 | 248 |
#if 0 |
... | ... |
@@ -274,18 +279,20 @@ cli_pdf(const char *dir, int desc) |
274 | 274 |
rc = CL_EFORMAT; |
275 | 275 |
continue; |
276 | 276 |
} |
277 |
- streamlen = (size_t)ret; |
|
278 |
- /* free unused traling bytes */ |
|
279 |
- tmpbuf = cli_realloc(tmpbuf, streamlen); |
|
280 |
- /* |
|
281 |
- * Note that it will probably be both ascii85encoded |
|
282 |
- * and flateencoded |
|
283 |
- */ |
|
284 |
- if(is_flatedecode) { |
|
285 |
- const int zstat = flatedecode((unsigned char *)tmpbuf, streamlen, fout); |
|
286 |
- |
|
287 |
- if(zstat != Z_OK) |
|
288 |
- rc = CL_EZIP; |
|
277 |
+ if(ret) { |
|
278 |
+ streamlen = (size_t)ret; |
|
279 |
+ /* free unused trailing bytes */ |
|
280 |
+ tmpbuf = cli_realloc(tmpbuf, streamlen); |
|
281 |
+ /* |
|
282 |
+ * Note that it will probably be both |
|
283 |
+ * ascii85encoded and flateencoded |
|
284 |
+ */ |
|
285 |
+ if(is_flatedecode) { |
|
286 |
+ const int zstat = flatedecode((unsigned char *)tmpbuf, streamlen, fout); |
|
287 |
+ |
|
288 |
+ if(zstat != Z_OK) |
|
289 |
+ rc = CL_EZIP; |
|
290 |
+ } |
|
289 | 291 |
} |
290 | 292 |
free(tmpbuf); |
291 | 293 |
} else if(is_flatedecode) { |