Accepting request 517506 from graphics

1

OBS-URL: https://build.opensuse.org/request/show/517506
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/gifsicle?expand=0&rev=5
This commit is contained in:
Dominique Leuenberger 2017-08-18 13:06:44 +00:00 committed by Git OBS Bridge
commit e5732fa4b0
13 changed files with 62 additions and 511 deletions

View File

@ -1,18 +0,0 @@
Correct uninitialized-memory bug with zero-element colormaps.
Tim Strazzere report. Also fixed by a0a3651.
diff --git a/src/opttemplate.c b/src/opttemplate.c
index 1f96c41..407b940 100644
--- a/src/opttemplate.c
+++ b/src/opttemplate.c
@@ -146,8 +146,9 @@ X(apply_frame)(palindex_type *dst, Gif_Stream* gfs, Gif_Image* gfi,
for (i = 0; i < colormap->ncol; i++)
map[i] = colormap->col[i].pixel;
/* out-of-bounds colors map to 0, for the sake of argument */
+ y = colormap->ncol ? colormap->col[0].pixel : 0;
for (i = colormap->ncol; i < 256; i++)
- map[i] = colormap->col[0].pixel;
+ map[i] = y;
if (gfi->transparent >= 0 && gfi->transparent < 256)
map[gfi->transparent] = TRANSP;
else

View File

@ -1,260 +0,0 @@
diff --git a/configure.ac b/configure.ac
index a274546..f282400 100644
--- a/configure.ac
+++ b/configure.ac
@@ -138,7 +138,7 @@ AC_REPLACE_FUNCS([strerror])
AC_CHECK_FUNCS([strtoul mkstemp])
AC_SEARCH_LIBS([pow], [m], [AC_DEFINE([HAVE_POW], [1], [Define to 1 if you have the `pow' function.])])
-AC_CHECK_HEADERS([sys/select.h inttypes.h unistd.h])
+AC_CHECK_HEADERS([sys/select.h sys/stat.h inttypes.h unistd.h])
dnl
diff --git a/src/gifdiff.c b/src/gifdiff.c
index 790ed31..317c5df 100644
--- a/src/gifdiff.c
+++ b/src/gifdiff.c
@@ -118,11 +118,10 @@ apply_image(int is_second, Gif_Stream *gfs, int imageno, uint16_t background)
Gif_Colormap *gfcm = gfi->local ? gfi->local : gfs->global;
/* set up colormap */
- for (i = 0; i < 256; i++)
+ for (i = 0; i < gfcm->ncol; ++i)
+ map[i] = gfcm->col[i].pixel;
+ for (i = gfcm->ncol; i < 256; ++i)
map[i] = 1;
- if (gfs)
- for (i = 0; i < gfcm->ncol; i++)
- map[i] = gfcm->col[i].pixel;
if (gfi->transparent >= 0 && gfi->transparent < 256)
map[gfi->transparent] = TRANSP;
@@ -458,7 +457,7 @@ gifread_error(Gif_Stream* gfs, Gif_Image* gfi,
static int same_error_count = 0;
int which_image = Gif_ImageNumber(gfs, gfi);
const char *filename = gfs->landmark;
- if (gfs && which_image < 0)
+ if (which_image < 0)
which_image = gfs->nimages;
if (gifread_error_count == 0) {
diff --git a/src/giffunc.c b/src/giffunc.c
index 5564326..71d8b74 100644
--- a/src/giffunc.c
+++ b/src/giffunc.c
@@ -87,8 +87,10 @@ Gif_Colormap *
Gif_NewFullColormap(int count, int capacity)
{
Gif_Colormap *gfcm = Gif_New(Gif_Colormap);
- if (!gfcm || capacity <= 0 || count < 0)
+ if (!gfcm || capacity <= 0 || count < 0) {
+ Gif_Delete(gfcm);
return 0;
+ }
if (count > capacity)
capacity = count;
gfcm->ncol = count;
diff --git a/src/gifread.c b/src/gifread.c
index 363fa24..bcab1e3 100644
--- a/src/gifread.c
+++ b/src/gifread.c
@@ -548,7 +548,7 @@ Gif_FullUncompressImage(Gif_Stream* gfs, Gif_Image* gfi,
gfc.handler = h;
gfc.errors[0] = gfc.errors[1] = 0;
- if (gfi && gfc.prefix && gfc.suffix && gfc.length && gfi->compressed) {
+ if (gfc.prefix && gfc.suffix && gfc.length && gfi->compressed) {
make_data_reader(&grr, gfi->compressed, gfi->compressed_len);
ok = uncompress_image(&gfc, gfi, &grr);
}
@@ -802,7 +802,6 @@ read_gif(Gif_Reader *grr, int read_flags,
gfs = Gif_NewStream();
gfi = Gif_NewImage();
- gfs->landmark = landmark;
gfc.stream = gfs;
gfc.prefix = Gif_NewArray(Gif_Code, GIF_MAX_CODE);
@@ -814,6 +813,7 @@ read_gif(Gif_Reader *grr, int read_flags,
if (!gfs || !gfi || !gfc.prefix || !gfc.suffix || !gfc.length)
goto done;
+ gfs->landmark = landmark;
GIF_DEBUG(("\nGIF"));
if (!read_logical_screen_descriptor(gfs, grr))
diff --git a/src/gifsicle.c b/src/gifsicle.c
index fdb44ed..b4cedbc 100644
--- a/src/gifsicle.c
+++ b/src/gifsicle.c
@@ -513,8 +513,10 @@ gifread_error(Gif_Stream* gfs, Gif_Image* gfi,
if (last_message[0] == 0)
different_error_count++;
same_error_count++;
- strcpy(last_message, message);
- strcpy(last_landmark, landmark);
+ strncpy(last_message, message, sizeof(last_message));
+ last_message[sizeof(last_message) - 1] = 0;
+ strncpy(last_landmark, landmark, sizeof(last_landmark));
+ last_landmark[sizeof(last_landmark) - 1] = 0;
last_is_error = is_error;
if (different_error_count == 11) {
if (!(gfi && gfi->user_flags))
@@ -618,7 +620,7 @@ close_giffile(FILE *f, int final)
void
input_stream(const char *name)
{
- static char *component_namebuf = 0;
+ char* component_namebuf;
FILE *f;
Gif_Stream *gfs;
int i;
@@ -651,11 +653,11 @@ input_stream(const char *name)
/* change filename for component files */
componentno++;
if (componentno > 1) {
- free(component_namebuf);
component_namebuf = (char*) malloc(strlen(main_name) + 10);
sprintf(component_namebuf, "%s~%d", main_name, componentno);
name = component_namebuf;
- }
+ } else
+ component_namebuf = 0;
/* check for empty file */
i = getc(f);
@@ -664,8 +666,7 @@ input_stream(const char *name)
lerror(name, "empty file");
else if (nextfile)
lerror(name, "no more images in file");
- close_giffile(f, 1);
- return;
+ goto error;
}
ungetc(i, f);
@@ -685,8 +686,7 @@ input_stream(const char *name)
Gif_DeleteStream(gfs);
if (verbosing)
verbose_close('>');
- close_giffile(f, 1);
- return;
+ goto error;
}
/* special processing for components after the first */
@@ -768,9 +768,15 @@ input_stream(const char *name)
gfs->refcount++;
/* Read more files. */
+ free(component_namebuf);
if ((gif_read_flags & GIF_READ_TRAILING_GARBAGE_OK) && !nextfile)
goto retry_file;
close_giffile(f, 0);
+ return;
+
+ error:
+ free(component_namebuf);
+ close_giffile(f, 1);
}
void
diff --git a/src/gifwrite.c b/src/gifwrite.c
index 38d6084..3d0dfc2 100644
--- a/src/gifwrite.c
+++ b/src/gifwrite.c
@@ -304,7 +304,7 @@ write_compressed_data(Gif_Image *gfi,
unsigned ncap = bufcap * 2 + (24 << 3);
uint8_t *nbuf = Gif_NewArray(uint8_t, ncap >> 3);
if (!nbuf)
- return 0;
+ goto error;
memcpy(nbuf, buf, bufcap >> 3);
if (buf != stack_buffer)
Gif_DeleteArray(buf);
@@ -451,8 +451,12 @@ write_compressed_data(Gif_Image *gfi,
if (buf != stack_buffer)
Gif_DeleteArray(buf);
-
return 1;
+
+ error:
+ if (buf != stack_buffer)
+ Gif_DeleteArray(buf);
+ return 0;
}
diff --git a/src/gifx.c b/src/gifx.c
index 93eab8d..fb192dd 100644
--- a/src/gifx.c
+++ b/src/gifx.c
@@ -842,8 +842,8 @@ Gif_DeleteXContext(Gif_XContext *gfx)
if (gfx->mask_gc)
XFreeGC(gfx->display, gfx->mask_gc);
Gif_DeleteArray(gfx->closest);
- Gif_Delete(gfx);
Gif_RemoveDeletionHook(GIF_T_COLORMAP, delete_colormap_hook, gfx);
+ Gif_Delete(gfx);
}
diff --git a/src/quantize.c b/src/quantize.c
index c07a9b9..dc780d5 100644
--- a/src/quantize.c
+++ b/src/quantize.c
@@ -1690,7 +1690,7 @@ colormap_stream(Gif_Stream* gfs, Gif_Colormap* new_cm, Gt_OutputData* od)
}
/* map the image data, transparencies, and background */
- if (gfs->global && gfs->background < gfs->global->ncol)
+ if (gfs->background < gfs->global->ncol)
gfs->background = map[gfs->background];
for (imagei = 0; imagei < gfs->nimages; imagei++) {
Gif_Image *gfi = gfs->images[imagei];
diff --git a/src/xform.c b/src/xform.c
index 3173591..aa62c55 100644
--- a/src/xform.c
+++ b/src/xform.c
@@ -20,6 +20,10 @@
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
+#if HAVE_SYS_TYPES_H && HAVE_SYS_STAT_H
+# include <sys/types.h>
+# include <sys/stat.h>
+#endif
#ifndef M_PI
/* -std=c89 does not define M_PI */
# define M_PI 3.14159265358979323846
@@ -152,8 +156,12 @@ pipe_color_transformer(Gif_Colormap *gfcm, void *thunk)
char *new_command;
#ifdef HAVE_MKSTEMP
- if (mkstemp(tmp_file) < 0)
- fatal_error("can%,t create temporary file!");
+ {
+ mode_t old_mode = umask(077);
+ if (mkstemp(tmp_file) < 0)
+ fatal_error("can%,t create temporary file!");
+ umask(old_mode);
+ }
#else
if (!tmp_file)
fatal_error("can%,t create temporary file!");
@@ -562,11 +570,11 @@ static void scale_image_output_row(scale_context* sctx, scale_color* sc,
+ gfo->left];
for (xo = 0; xo != gfo->width; ++xo)
- if (sc[xo].a[3] <= KC_MAX / 4)
+ if (sc[xo].a[3] <= (int) (KC_MAX / 4))
oscr[xo] = kac_transparent();
else {
/* don't effectively mix partially transparent pixels with black */
- if (sc[xo].a[3] <= KC_MAX * 31 / 32)
+ if (sc[xo].a[3] <= (int) (KC_MAX * 31 / 32))
for (k = 0; k != 3; ++k)
sc[xo].a[k] *= KC_MAX / sc[xo].a[3];
/* find closest color */

View File

@ -1,20 +0,0 @@
diff --git a/src/gifsicle.c b/src/gifsicle.c
index b4cedbc..e326c84 100644
--- a/src/gifsicle.c
+++ b/src/gifsicle.c
@@ -58,10 +58,11 @@ static int no_ignore_errors = 0;
#define CHANGED(next, flag) (((next) & (1<<(flag))) != 0)
#define UNCHECKED_MARK_CH(where, what) \
next_##where |= 1<<what;
-#define MARK_CH(where, what) \
- if (CHANGED(next_##where, what)) \
- redundant_option_warning(where##_option_types[what]); \
- UNCHECKED_MARK_CH(where, what)
+#define MARK_CH(where, what) do { \
+ if (CHANGED(next_##where, what)) \
+ redundant_option_warning(where##_option_types[what]); \
+ UNCHECKED_MARK_CH(where, what); \
+ } while (0)
/* frame option types */
static int next_frame = 0;

View File

@ -1,15 +0,0 @@
diff --git a/gifsicle.1 b/gifsicle.1
index fe4b58e..6640177 100644
--- a/gifsicle.1
+++ b/gifsicle.1
@@ -320,7 +320,9 @@ option if you are having problems with a particular image.
.Op \-\-conserve\-memory
'
Conserve memory usage at the expense of processing time. This may be useful
-if you are processing large GIFs on a computer without very much memory.
+if you are processing large GIFs on a computer without very much memory. Or
+say
+.Op \-\-no\-conserve\-memory .
'
.Sp
.TP

View File

@ -1,13 +0,0 @@
diff --git a/src/support.c b/src/support.c
index ad4997b..2094b0a 100644
--- a/src/support.c
+++ b/src/support.c
@@ -314,7 +314,7 @@ safe_puts(const char *s, uint32_t len, FILE *f)
case '\v': fputs("\\v", f); break;
case '\\': fputs("\\\\", f); break;
case 0: if (len > 1) fputs("\\000", f); break;
- default: fprintf(f, "\\%03o", *s); break;
+ default: fprintf(f, "\\%03o", (unsigned char) *s); break;
}
}
if (last_safe != s) {

View File

@ -1,60 +0,0 @@
From 1a29f8f5a0e19a2c671eea3604bb43ad0de8c467 Mon Sep 17 00:00:00 2001
From: Eddie Kohler <ekohler@gmail.com>
Date: Fri, 7 Apr 2017 16:55:09 -0400
Subject: [PATCH] Correct an out-of-bounds read found by @b0b0505 using afl.
---
src/merge.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/merge.c b/src/merge.c
index 699c8ca..47486b7 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -257,6 +257,7 @@ merge_image(Gif_Stream *dest, Gif_Stream *src, Gif_Image *srci,
Gt_Frame* srcfr, int same_compressed_ok)
{
Gif_Colormap *imagecm;
+ int imagecm_ncol;
int i;
Gif_Colormap *localcm = 0;
Gif_Colormap *destcm = dest->global;
@@ -268,12 +269,14 @@ merge_image(Gif_Stream *dest, Gif_Stream *src, Gif_Image *srci,
uint8_t used[256]; /* used[output pixval K] == 1 iff K was used
in the image */
+
Gif_Image *desti;
/* mark colors that were actually used in this image */
imagecm = srci->local ? srci->local : src->global;
+ imagecm_ncol = imagecm ? imagecm->ncol : 0;
merge_image_input_colors(inused, srci);
- for (i = imagecm ? imagecm->ncol : 0; i != 256; ++i)
+ for (i = imagecm_ncol; i != 256; ++i)
if (inused[i]) {
lwarning(srcfr->input_filename, "some colors undefined by colormap");
break;
@@ -286,18 +289,14 @@ merge_image(Gif_Stream *dest, Gif_Stream *src, Gif_Image *srci,
/* Merge the colormap */
if (merge_colormap_if_possible(dest->global, imagecm)) {
/* Create 'map' and 'used' for global colormap. */
- for (i = 0; i != 256; ++i)
- if (inused[i]) {
- if (imagecm && i < imagecm->ncol)
- map[i] = imagecm->col[i].pixel;
- else
- map[i] = 0;
- }
+ for (i = 0; i != imagecm_ncol; ++i)
+ if (inused[i])
+ map[i] = imagecm->col[i].pixel;
} else {
/* Need a local colormap. */
destcm = localcm = Gif_NewFullColormap(0, 256);
- for (i = 0; i != 256; ++i)
+ for (i = 0; i != imagecm_ncol; ++i)
if (inused[i]) {
map[i] = localcm->ncol;
localcm->col[localcm->ncol] = imagecm->col[i];

View File

@ -1,39 +0,0 @@
diff --git a/src/gifsicle.c b/src/gifsicle.c
index d474dfc..c0de94b 100644
--- a/src/gifsicle.c
+++ b/src/gifsicle.c
@@ -521,8 +521,6 @@ show_frame(int imagenumber, int usename)
* input a stream
**/
-static int gifread_error_count;
-
static void
gifread_error(Gif_Stream* gfs, Gif_Image* gfi,
int is_error, const char* message)
@@ -732,15 +730,20 @@ input_stream(const char *name)
verbose_open('<', name);
/* read file */
- gifread_error_count = 0;
- gfs = Gif_FullReadFile(f, gif_read_flags | GIF_READ_COMPRESSED,
- name, gifread_error);
+ {
+ int old_error_count = error_count;
+ gfs = Gif_FullReadFile(f, gif_read_flags | GIF_READ_COMPRESSED,
+ name, gifread_error);
+ if ((!gfs || (Gif_ImageCount(gfs) == 0 && gfs->errors > 0))
+ && componentno != 1)
+ lerror(name, "trailing garbage ignored");
+ if (!no_ignore_errors)
+ error_count = old_error_count;
+ }
if (!gfs || (Gif_ImageCount(gfs) == 0 && gfs->errors > 0)) {
if (componentno == 1)
lerror(name, "file not in GIF format");
- else
- lerror(name, "trailing garbage ignored");
Gif_DeleteStream(gfs);
if (verbosing)
verbose_close('>');

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4585d2e683d7f68eb8fcb15504732d71d7ede48ab5963e61915201f9e68305be
size 564670

3
gifsicle-1.90.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2d73b096752d58fa604cea559199aa6f55b45a3ec833898f94ff7997d22b834d
size 571910

View File

@ -1,3 +1,42 @@
-------------------------------------------------------------------
Fri Aug 18 09:59:28 CEST 2017 - manfred99@gmx.ch
- drop patch fix_use-after-free.patch
- upgrade to version 1.90:
* Kill a use-after-free error reported by @junxzm1990.
-------------------------------------------------------------------
Mon Aug 14 11:03:52 CEST 2017 - manfred99@gmx.ch
- drop SLE 11 support in spec file
-------------------------------------------------------------------
Sun Aug 13 22:56:53 CEST 2017 - manfred99@gmx.ch
- use spec description of the in-tree spec file.
- add fix_use-after-free.patch:
upstream fix, commit 81fd7823f6d9c85ab598bc850e40382068361185
- drop following patches:
* fix-escapes-in-info-mode.patch
* coverity.patch
* coverity2.patch
* document-no-conserve-memory.patch
* fix-out-of-bound.patch
* no_status-1_when_valid_output.patch
* fix_ignore-errors_and_merge_mode.patch
* initialize_missing_image.patch
* correct_zero-element_colormaps.patch
- upgrade to version 1.89:
* Add SIMD support for resizing. When enabled this improves resize
performance enormously for complex resize methods.
* Add thread support for resizing. `-j[NTHREADS]` tells gifsicle to use
up to NTHREADS threads to resize an input image. There are several
caveats---multiple threads can be only used on unoptimized images.
Thanks to Github user @wilkesybear.
* Quashed several crashes and undefined behaviors. Thanks to Github users
including @pornel, @strazzere, and @b0b0505.
* Minor bug fixes.
-------------------------------------------------------------------
Mon Jul 10 10:54:17 UTC 2017 - jengelh@inai.de

View File

@ -17,79 +17,52 @@
Name: gifsicle
Version: 1.88
Version: 1.90
Release: 0
Summary: Creating and editing GIF images and animations
License: GPL-2.0
Group: Productivity/Graphics/Other
Url: https://www.lcdf.org/gifsicle/
Source: https://www.lcdf.org/gifsicle/%{name}-%{version}.tar.gz
Patch0: fix-escapes-in-info-mode.patch
Patch1: coverity.patch
Patch2: coverity2.patch
Patch3: document-no-conserve-memory.patch
Patch4: fix-out-of-bound.patch
Patch5: no_status-1_when_valid_output.patch
Patch6: fix_ignore-errors_and_merge_mode.patch
Patch7: initialize_missing_image.patch
Patch8: correct_zero-element_colormaps.patch
Obsoletes: ungifsicle < %{version}
Provides: ungifsicle = %{version}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: autoconf
BuildRequires: automake
%if 0%{?suse_version} == 1110
BuildRequires: xorg-x11-libX11
BuildRequires: xorg-x11-libX11-devel
%else
BuildRequires: pkgconfig(x11)
%if 0%{?fedora_version} || 0%{?rhel_version} || 0%{?centos_version}
BuildRequires: perl-Time-HiRes
%endif
%description
Gifsicle twaddles GIF image files in a variety of ways.
Gifsicle manipulates GIF image files on the
command line. It supports merging several GIFs
into a GIF animation; exploding an animation into
its component frames; changing individual frames
in an animation; turning interlacing on and off;
adding transparency; adding delays, disposals, and
looping to animations; adding or removing
comments; optimizing animations for space; and
changing images' colormaps, among other things.
It supports merging several GIFs into a GIF animation; exploding an
animation into its component frames; changing individual frames in an
animation; turning interlacing on and off; adding transparency; adding
delays, disposals, and looping to animations; adding or removing
comments; flipping and rotation; optimizing animations for space; and
changing images' colormaps, among other things. Extensive command-line
options control which, if any, of these occur.
Gifview, a companion program requiring X11, displays GIF images and
animations on an X display. It can display multi-frame GIFs either as
slideshows, displaying one frame at a time, or as real-time animations.
Gifdiff, another companion program, checks two GIF files for identical
visual appearance. This is probably most useful for testing
GIF-manipulating software.
The gifsicle package contains two other programs:
gifview, a lightweight GIF viewer for X, can show
animations as slideshows or in real time, and
gifdiff compares two GIFs for identical visual
appearance.
%prep
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
autoreconf
%build
%configure
make %{?_smp_mflags}
%check
make check
make %{?_smp_mflags} check
%install
make install DESTDIR=%{buildroot}
%make_install
%files
%defattr(-,root,root)
%doc COPYING NEWS README.md
%doc COPYING NEWS.md README.md
%{_bindir}/gifdiff
%{_bindir}/gifsicle
%{_bindir}/gifview

View File

@ -1,15 +0,0 @@
Set missing image data to 0, rather than leaving it uninitialized.
Avoid valgrind warnings.
diff --git a/src/gifread.c b/src/gifread.c
index d2021ee..e9a58dd 100644
--- a/src/gifread.c
+++ b/src/gifread.c
@@ -373,6 +373,7 @@ read_image_data(Gif_Context *gfc, Gif_Reader *grr)
sprintf(buf, "missing %ld %s of image data", delta,
delta == 1 ? "pixel" : "pixels");
gif_read_error(gfc, 1, buf);
+ memset(&gfc->image[gfc->decodepos], 0, delta);
} else if (delta < -1) {
/* One pixel of superfluous data is OK; that could be the
code == next_code case. */

View File

@ -1,21 +0,0 @@
diff --git a/src/support.c b/src/support.c
index 2094b0a..fe247a8 100644
--- a/src/support.c
+++ b/src/support.c
@@ -1109,14 +1109,14 @@ find_color_or_error(Gif_Color *color, Gif_Stream *gfs, Gif_Image *gfi,
return color->pixel;
else {
if (color_context)
- lerror(gfs->landmark, "%s color out of range", color_context);
+ lwarning(gfs->landmark, "%s color out of range", color_context);
return -1;
}
}
index = Gif_FindColor(gfcm, color);
if (index < 0 && color_context)
- lerror(gfs->landmark, "%s color not in colormap", color_context);
+ lwarning(gfs->landmark, "%s color not in colormap", color_context);
return index;
}