projects
/
privoxy.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
configure: Bump SOURCE_DATE_EPOCH
[privoxy.git]
/
deanimate.c
diff --git
a/deanimate.c
b/deanimate.c
index
d583bc6
..
a6759da
100644
(file)
--- a/
deanimate.c
+++ b/
deanimate.c
@@
-1,4
+1,3
@@
-const char deanimate_rcs[] = "$Id: deanimate.c,v 1.20 2009/05/16 13:27:20 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/deanimate.c,v $
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/deanimate.c,v $
@@
-7,15
+6,11
@@
const char deanimate_rcs[] = "$Id: deanimate.c,v 1.20 2009/05/16 13:27:20 fabian
* fly. High-level functions include:
* - Deanimation of GIF images
*
* fly. High-level functions include:
* - Deanimation of GIF images
*
- * Functions declared include: gif_deanimate, buf_free,
- * buf_copy, buf_getbyte, gif_skip_data_block
- * and gif_extract_image
- *
* Copyright : Written by and Copyright (C) 2001 - 2004, 2006 by the
* Copyright : Written by and Copyright (C) 2001 - 2004, 2006 by the
- *
SourceForge Privoxy team. http
://www.privoxy.org/
+ *
Privoxy team. https
://www.privoxy.org/
*
* Based on the GIF file format specification (see
*
* Based on the GIF file format specification (see
- * http://tronche.com/computer-graphics/gif/gif89a.html)
+ * http
s
://tronche.com/computer-graphics/gif/gif89a.html)
* and ideas from the Image::DeAnim Perl module by
* Ken MacFarlane, <ksm+cpan@universal.dca.net>
*
* and ideas from the Image::DeAnim Perl module by
* Ken MacFarlane, <ksm+cpan@universal.dca.net>
*
@@
-45,13
+40,11
@@
const char deanimate_rcs[] = "$Id: deanimate.c,v 1.20 2009/05/16 13:27:20 fabian
#include <string.h>
#include <fcntl.h>
#include <string.h>
#include <fcntl.h>
-#include "errlog.h"
#include "project.h"
#include "project.h"
+#include "errlog.h"
#include "deanimate.h"
#include "miscutil.h"
#include "deanimate.h"
#include "miscutil.h"
-const char deanimate_h_rcs[] = DEANIMATE_H_VERSION;
-
/*********************************************************************
*
* Function : buf_free
/*********************************************************************
*
* Function : buf_free
@@
-138,6
+131,14
@@
static int buf_extend(struct binbuffer *buf, size_t length)
*********************************************************************/
static int buf_copy(struct binbuffer *src, struct binbuffer *dst, size_t length)
{
*********************************************************************/
static int buf_copy(struct binbuffer *src, struct binbuffer *dst, size_t length)
{
+ /*
+ * Sanity check: Make sure the source buffer contains
+ * data and there's work to be done.
+ */
+ if (src->buffer == NULL || src->size == 0 || length == 0)
+ {
+ return 1;
+ }
/*
* Sanity check: Can't copy more data than we have
/*
* Sanity check: Can't copy more data than we have
@@
-311,8
+312,8
@@
static int gif_extract_image(struct binbuffer *src, struct binbuffer *dst)
* an (optional) image block and an arbitrary number
* of image extension blocks, produce an output GIF with
* only one image block that contains the last image
* an (optional) image block and an arbitrary number
* of image extension blocks, produce an output GIF with
* only one image block that contains the last image
- * (extens
t
ion) block of the original.
- * Also strip Comments, Application extens
t
ions, etc.
+ * (extension) block of the original.
+ * Also strip Comments, Application extensions, etc.
*
* Parameters :
* 1 : src = Pointer to the source binbuffer
*
* Parameters :
* 1 : src = Pointer to the source binbuffer
@@
-332,6
+333,10
@@
int gif_deanimate(struct binbuffer *src, struct binbuffer *dst, int get_first_im
{
return 1;
}
{
return 1;
}
+ if (src->size <= 10)
+ {
+ return 1;
+ }
c = buf_getbyte(src, 10);
c = buf_getbyte(src, 10);
@@
-353,7
+358,7
@@
int gif_deanimate(struct binbuffer *src, struct binbuffer *dst, int get_first_im
/*
* Look for global colormap and copy if found.
*/
/*
* Look for global colormap and copy if found.
*/
- if(c & 0x80)
+ if
(c & 0x80)
{
int map_length = 3 * (1 << ((c & 0x07) + 1));
if (map_length <= 0)
{
int map_length = 3 * (1 << ((c & 0x07) + 1));
if (map_length <= 0)
@@
-371,10
+376,7
@@
int gif_deanimate(struct binbuffer *src, struct binbuffer *dst, int get_first_im
/*
* Reserve a buffer for the current image block
*/
/*
* Reserve a buffer for the current image block
*/
- if (NULL == (image = (struct binbuffer *)zalloc(sizeof(*image))))
- {
- return 1;
- }
+ image = zalloc_or_die(sizeof(*image));
/*
* Parse the GIF block by block and copy the relevant
/*
* Parse the GIF block by block and copy the relevant
@@
-385,9
+387,11
@@
int gif_deanimate(struct binbuffer *src, struct binbuffer *dst, int get_first_im
switch(buf_getbyte(src, 0))
{
/*
switch(buf_getbyte(src, 0))
{
/*
- * End-of-GIF Marker: Append current image and return
+ * End-of-GIF Marker: Append current image if we got
+ * one and return.
*/
case 0x3b:
*/
case 0x3b:
+ if (image->size == 0) goto failed;
goto write;
/*
goto write;
/*