Accepting request 886087 from multimedia:libs

OBS-URL: https://build.opensuse.org/request/show/886087
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/libcaca?expand=0&rev=46
This commit is contained in:
Dominique Leuenberger 2021-04-18 19:45:13 +00:00 committed by Git OBS Bridge
commit 1322e19dc0
3 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,50 @@
Index: libcaca-da28e9684ef445ac8d42745644336b8a75c01855/caca/codec/export.c
===================================================================
--- libcaca-da28e9684ef445ac8d42745644336b8a75c01855.orig/caca/codec/export.c
+++ libcaca-da28e9684ef445ac8d42745644336b8a75c01855/caca/codec/export.c
@@ -944,21 +944,21 @@ static void *export_tga(caca_canvas_t co
cur = data = malloc(*bytes);
/* ID Length */
- cur += sprintf(cur, "%c", 0);
+ *cur++ = 0;
/* Color Map Type: no colormap */
- cur += sprintf(cur, "%c", 0);
+ *cur++ = 0;
/* Image Type: uncompressed truecolor */
- cur += sprintf(cur, "%c", 2);
+ *cur++ = 2;
/* Color Map Specification: no color map */
memset(cur, 0, 5); cur += 5;
/* Image Specification */
- cur += sprintf(cur, "%c%c", 0, 0); /* X Origin */
- cur += sprintf(cur, "%c%c", 0, 0); /* Y Origin */
- cur += sprintf(cur, "%c%c", w & 0xff, w >> 8); /* Width */
- cur += sprintf(cur, "%c%c", h & 0xff, h >> 8); /* Height */
- cur += sprintf(cur, "%c", 32); /* Pixel Depth */
- cur += sprintf(cur, "%c", 40); /* Image Descriptor */
+ *cur++ = 0; *cur++ = 0; /* X Origin */
+ *cur++ = 0; *cur++ = 0; /* Y Origin */
+ *cur++ = w & 0xff; *cur++ = w >> 8; /* Width */
+ *cur++ = h & 0xff; *cur++ = h >> 8; /* Height */
+ *cur++ = 32; /* Pixel Depth */
+ *cur++ = 40; /* Image Descriptor */
/* Image ID: no ID */
/* Color Map Data: no colormap */
@@ -995,9 +995,13 @@ static void *export_troff(caca_canvas_t
* + 4 bytes = 33
* Each line has a \n (1) and maybe 0xc2 0xa0 (2)
* Header has .nf\n (3)
+ * Kludge alert:
+ * The sprintf functions all append a NUL byte, so
+ * add one byte for any terminating NUL byte,
+ * but don't tell the caller.
*/
*bytes = 3 + cv->height * 3 + (cv->width * cv->height * 33);
- cur = data = malloc(*bytes);
+ cur = data = malloc(*bytes + 1); /* Add space for a terminating NUL byte */
cur += sprintf(cur, ".nf\n");

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Fri Apr 16 15:57:48 UTC 2021 - Josef Möllers <josef.moellers@suse.com>
- The problem is due to the fact that the images in the POC have
a size of 0x0 and thus, when exporting, no data is written for
the image bits.
However, space is allocated for the header only, not taking
into account that sprintf appends a NUL byte.
[bsc#1184751, bsc#1184752, bsc1184751-add-space-for-NUL-byte.patch]
-------------------------------------------------------------------
Fri Feb 26 13:58:41 UTC 2021 - Josef Möllers <josef.moellers@suse.com>

View File

@ -38,6 +38,7 @@ Patch11: libcaca-variable-type.patch
Patch12: Bug1120502-add_cast_to_prevent_overflow.patch
Patch13: Bug1143286_libcaca_configure_ac_chg_for_lto.patch
Patch14: libcaca-bsc1182731-prevent-overflow.patch
Patch99: bsc1184751-add-space-for-NUL-byte.patch
BuildRequires: doxygen
BuildRequires: fdupes
BuildRequires: freeglut-devel
@ -144,6 +145,7 @@ drawing, triangle filling and sprite blitting.
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch99 -p1
RUBY="ruby-`echo %{rb_ver} | sed 's|\.[^\.]*$||'`"
find . -type f -exec sed -i "s|ruby-1.9|$RUBY|" \{\} \;
pushd python