Accepting request 1036244 from multimedia:libs

- add patch [libcaca-autoconf-2.69.patch]
  * Don't force autoconf to be at version 2.71

- Upgrade to 0.99.beta20
  * IPv6 support in cacaserver
  * fixed a bug from 2004 that caused PDF documentation generation to fail
  * memory allocation functions are now more robust
  * numerous fixes for memory leaks and invalid memory accesses:
    * CVE-2021-30498
    * CVE-2021-30499
    * CVE-2021-3410
    * CVE-2018-20546
    * CVE-2018-20547
    * CVE-2018-20545
    * CVE-2018-20548
    * CVE-2018-20549
- Dropped upstream fixed patches
  * libcaca-bsc1182731-prevent-overflow.patch
  * libcaca-variable-type.patch
  * Bug1120502-add_cast_to_prevent_overflow.patch

OBS-URL: https://build.opensuse.org/request/show/1036244
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/libcaca?expand=0&rev=49
This commit is contained in:
Dominique Leuenberger 2022-11-24 11:22:02 +00:00 committed by Git OBS Bridge
commit b24d8490c3
15 changed files with 92 additions and 740 deletions

View File

@ -1,35 +0,0 @@
Author: Josef Möllers <jmoellers@suse.de>
Index: libcaca-da28e9684ef445ac8d42745644336b8a75c01855/caca/dither.c
===================================================================
--- libcaca-da28e9684ef445ac8d42745644336b8a75c01855.orig/caca/dither.c
+++ libcaca-da28e9684ef445ac8d42745644336b8a75c01855/caca/dither.c
@@ -991,10 +991,10 @@ int caca_dither_bitmap(caca_canvas_t *cv
/* First get RGB */
if(d->antialias)
{
- fromx = (x - x1) * w / deltax;
- fromy = (y - y1) * h / deltay;
- tox = (x - x1 + 1) * w / deltax;
- toy = (y - y1 + 1) * h / deltay;
+ fromx = (uint64_t)(x - x1) * w / deltax;
+ fromy = (uint64_t)(y - y1) * h / deltay;
+ tox = (uint64_t)(x - x1 + 1) * w / deltax;
+ toy = (uint64_t)(y - y1 + 1) * h / deltay;
/* We want at least one pixel */
if(tox == fromx) tox++;
@@ -1017,10 +1017,10 @@ int caca_dither_bitmap(caca_canvas_t *cv
}
else
{
- fromx = (x - x1) * w / deltax;
- fromy = (y - y1) * h / deltay;
- tox = (x - x1 + 1) * w / deltax;
- toy = (y - y1 + 1) * h / deltay;
+ fromx = (uint64_t)(x - x1) * w / deltax;
+ fromy = (uint64_t)(y - y1) * h / deltay;
+ tox = (uint64_t)(x - x1 + 1) * w / deltax;
+ toy = (uint64_t)(y - y1 + 1) * h / deltay;
/* tox and toy can overflow the canvas, but they cannot overflow
* when averaged with fromx and fromy because these are guaranteed

View File

@ -12,23 +12,25 @@ Signed-off-by: Michel Normand <normand@linux.vnet.ibm.com>
configure.ac | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: libcaca-da28e9684ef445ac8d42745644336b8a75c01855/configure.ac
Index: libcaca-0.99.beta20/configure.ac
===================================================================
--- libcaca-da28e9684ef445ac8d42745644336b8a75c01855.orig/configure.ac
+++ libcaca-da28e9684ef445ac8d42745644336b8a75c01855/configure.ac
@@ -145,13 +145,13 @@ AC_TRY_COMPILE([#include <windows.h>],[S
--- libcaca-0.99.beta20.orig/configure.ac
+++ libcaca-0.99.beta20/configure.ac
@@ -146,7 +146,7 @@ AC_COMPILE_IFELSE(
[AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for fsin/fcos)
-AC_TRY_COMPILE([],[double x; asm volatile("fsin; fcos":"=t"(x):);],
+AC_TRY_LINK([],[double x; asm volatile("fsin; fcos":"=t"(x):);],
[AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_FSIN_FCOS, 1, [Define to 1 if you have the fsin and fcos instructions.])],
-AC_COMPILE_IFELSE(
+AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[]],
[[double x; asm volatile("fsin; fcos":"=t"(x):);]])],
@@ -155,7 +155,7 @@ AC_COMPILE_IFELSE(
[AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for fldln2/fxch/fyl2x)
-AC_TRY_COMPILE([],[double x; asm volatile("fldln2; fldln2; fxch; fyl2x":"=t"(x):);],
+AC_TRY_LINK([],[double x; asm volatile("fldln2; fldln2; fxch; fyl2x":"=t"(x):);],
[AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_FLDLN2, 1, [Define to 1 if you have the fldln2 and other floating point instructions.])],
[AC_MSG_RESULT(no)])
-AC_COMPILE_IFELSE(
+AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[]],
[[double x; asm volatile("fldln2; fldln2; fxch; fyl2x":"=t"(x):);]])],

View File

@ -1,18 +1,18 @@
Index: libcaca-da28e9684ef445ac8d42745644336b8a75c01855/caca/codec/export.c
Index: libcaca-0.99.beta20/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
--- libcaca-0.99.beta20.orig/caca/codec/export.c
+++ libcaca-0.99.beta20/caca/codec/export.c
@@ -969,22 +969,22 @@ static void *export_tga(caca_canvas_t co
cur = data = malloc(*bytes);
/* ID Length */
- cur += sprintf(cur, "%c", 0);
- cur += write_u8(cur, 0);
+ *cur++ = 0;
/* Color Map Type: no colormap */
- cur += sprintf(cur, "%c", 0);
- cur += write_u8(cur, 0);
+ *cur++ = 0;
/* Image Type: uncompressed truecolor */
- cur += sprintf(cur, "%c", 2);
- cur += write_u8(cur, 2);
+ *cur++ = 2;
/* Color Map Specification: no color map */
memset(cur, 0, 5); cur += 5;
@ -22,18 +22,20 @@ Index: libcaca-da28e9684ef445ac8d42745644336b8a75c01855/caca/codec/export.c
- 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 += write_u8(cur, 32); /* Pixel Depth */
- cur += write_u8(cur, 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
@@ -1020,9 +1020,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)
@ -44,7 +46,7 @@ Index: libcaca-da28e9684ef445ac8d42745644336b8a75c01855/caca/codec/export.c
*/
*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 = data = malloc(*bytes + 1); /* Add space for a terminating NUL byte */
cur += sprintf(cur, ".nf\n");
cur += write_string(cur, ".nf\n");

View File

@ -1,8 +1,8 @@
Index: doc/doxygen.cfg.in
===================================================================
--- doc/doxygen.cfg.in.orig 2010-01-03 04:54:32.000000000 +0200
+++ doc/doxygen.cfg.in 2010-11-20 07:32:05.000000000 +0200
@@ -1663,7 +1663,7 @@
--- doc/doxygen.cfg.in.orig
+++ doc/doxygen.cfg.in
@@ -1891,7 +1891,7 @@ USE_PDFLATEX = YES
# The default value is: NO.
# This tag requires that the tag GENERATE_LATEX is set to YES.

View File

@ -1,8 +1,8 @@
Index: caca/Makefile.am
===================================================================
--- caca/Makefile.am.orig 2012-05-14 11:37:31.929230228 +0200
+++ caca/Makefile.am 2012-05-14 11:39:48.458807793 +0200
@@ -55,7 +55,7 @@ libcaca_la_DEPENDENCIES = \
--- caca/Makefile.am.orig
+++ caca/Makefile.am
@@ -58,7 +58,7 @@ libcaca_la_DEPENDENCIES = \
$(NULL)
libcaca_la_CPPFLAGS = $(AM_CPPFLAGS) @CACA_CFLAGS@ -D__LIBCACA__
libcaca_la_LDFLAGS = -no-undefined -version-number @LT_VERSION@

View File

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

BIN
libcaca-0.99.beta20.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -1,8 +1,8 @@
Index: configure.ac
===================================================================
--- configure.ac.orig 2010-02-08 14:34:28.000000000 +0200
+++ configure.ac 2011-01-29 12:09:24.385753017 +0200
@@ -213,7 +213,7 @@ if test "${enable_x11}" != "no"; then
--- configure.ac.orig
+++ configure.ac
@@ -225,7 +225,7 @@ if test "${enable_x11}" != "no"; then
AC_CHECK_LIB(X11, XOpenDisplay,
[ac_cv_my_have_x11="yes"
if test -n "${x_includes}"; then X_CFLAGS="-I${x_includes}"; fi

View File

@ -0,0 +1,12 @@
Index: libcaca-0.99.beta20/configure.ac
===================================================================
--- libcaca-0.99.beta20.orig/configure.ac
+++ libcaca-0.99.beta20/configure.ac
@@ -1,6 +1,6 @@
AC_INIT([libcaca],[0.99.beta20])
-AC_PREREQ([2.71])
+AC_PREREQ([2.69])
AC_CONFIG_AUX_DIR(.auto)
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([foreign no-define tar-ustar silent-rules subdir-objects])

View File

@ -1,623 +0,0 @@
Index: libcaca-da28e9684ef445ac8d42745644336b8a75c01855/caca/canvas.c
===================================================================
--- libcaca-da28e9684ef445ac8d42745644336b8a75c01855.orig/caca/canvas.c
+++ libcaca-da28e9684ef445ac8d42745644336b8a75c01855/caca/canvas.c
@@ -45,6 +45,7 @@ static int caca_resize(caca_canvas_t *,
*
* If an error occurs, NULL is returned and \b errno is set accordingly:
* - \c EINVAL Specified width or height is invalid.
+ * - \c EOVERFLOW Specified width and height overflowed
* - \c ENOMEM Not enough memory for the requested canvas size.
*
* \param width The desired canvas width
@@ -200,6 +201,7 @@ int caca_unmanage_canvas(caca_canvas_t *
*
* If an error occurs, -1 is returned and \b errno is set accordingly:
* - \c EINVAL Specified width or height is invalid.
+ * - \c EOVERFLOW Specified width and height overflowed.
* - \c EBUSY The canvas is in use by a display driver and cannot be resized.
* - \c ENOMEM Not enough memory for the requested canvas size. If this
* happens, the canvas handle becomes invalid and should not be used.
@@ -365,6 +367,14 @@ int caca_resize(caca_canvas_t *cv, int w
{
int x, y, f, old_width, old_height, new_size, old_size;
+ /* Check for overflow */
+ new_size = width * height;
+ if (new_size < 0 || (width > 0 && new_size / width != height))
+ {
+ seterrno(EOVERFLOW);
+ return -1;
+ }
+
old_width = cv->width;
old_height = cv->height;
old_size = old_width * old_height;
@@ -375,7 +385,6 @@ int caca_resize(caca_canvas_t *cv, int w
* dirty rectangle handling */
cv->width = width;
cv->height = height;
- new_size = width * height;
/* If width or height is smaller (or both), we have the opportunity to
* reduce or even remove dirty rectangles */
Index: libcaca-da28e9684ef445ac8d42745644336b8a75c01855/caca/codec/import.c
===================================================================
--- libcaca-da28e9684ef445ac8d42745644336b8a75c01855.orig/caca/codec/import.c
+++ libcaca-da28e9684ef445ac8d42745644336b8a75c01855/caca/codec/import.c
@@ -61,6 +61,7 @@ static ssize_t import_caca(caca_canvas_t
*
* If an error occurs, -1 is returned and \b errno is set accordingly:
* - \c ENOMEM Not enough memory to allocate canvas.
+ * - \c EOVERFLOW Importing data caused a value overflow.
* - \c EINVAL Invalid format requested.
*
* \param cv A libcaca canvas in which to import the file.
Index: libcaca-da28e9684ef445ac8d42745644336b8a75c01855/caca/codec/text.c
===================================================================
--- libcaca-da28e9684ef445ac8d42745644336b8a75c01855.orig/caca/codec/text.c
+++ libcaca-da28e9684ef445ac8d42745644336b8a75c01855/caca/codec/text.c
@@ -46,7 +46,7 @@ ssize_t _import_text(caca_canvas_t *cv,
char const *text = (char const *)data;
unsigned int width = 0, height = 0, x = 0, y = 0, i;
- caca_set_canvas_size(cv, width, height);
+ caca_set_canvas_size(cv, 0, 0);
for(i = 0; i < size; i++)
{
@@ -70,15 +70,19 @@ ssize_t _import_text(caca_canvas_t *cv,
if(y >= height)
height = y + 1;
- caca_set_canvas_size(cv, width, height);
+ if (caca_set_canvas_size(cv, width, height) < 0)
+ return -1;
}
caca_put_char(cv, x, y, ch);
x++;
}
- if(y > height)
- caca_set_canvas_size(cv, width, height = y);
+ if (y > height)
+ {
+ if (caca_set_canvas_size(cv, width, height = y) < 0)
+ return -1;
+ }
return (ssize_t)size;
}
@@ -431,7 +435,8 @@ ssize_t _import_ansi(caca_canvas_t *cv,
{
savedattr = caca_get_attr(cv, -1, -1);
caca_set_attr(cv, im.clearattr);
- caca_set_canvas_size(cv, width = x + wch, height);
+ if (caca_set_canvas_size(cv, width = x + wch, height) < 0)
+ return -1;
caca_set_attr(cv, savedattr);
}
else
@@ -448,7 +453,8 @@ ssize_t _import_ansi(caca_canvas_t *cv,
caca_set_attr(cv, im.clearattr);
if(growy)
{
- caca_set_canvas_size(cv, width, height = y + 1);
+ if (caca_set_canvas_size(cv, width, height = y + 1) < 0)
+ return -1;
}
else
{
@@ -480,7 +486,8 @@ ssize_t _import_ansi(caca_canvas_t *cv,
{
savedattr = caca_get_attr(cv, -1, -1);
caca_set_attr(cv, im.clearattr);
- caca_set_canvas_size(cv, width, height = y);
+ if (caca_set_canvas_size(cv, width, height = y))
+ return -1;
caca_set_attr(cv, savedattr);
}
Index: libcaca-da28e9684ef445ac8d42745644336b8a75c01855/caca/t/canvas.cpp
===================================================================
--- libcaca-da28e9684ef445ac8d42745644336b8a75c01855.orig/caca/t/canvas.cpp
+++ libcaca-da28e9684ef445ac8d42745644336b8a75c01855/caca/t/canvas.cpp
@@ -53,18 +53,29 @@ public:
CPPUNIT_ASSERT_EQUAL(caca_get_canvas_width(cv), 0);
CPPUNIT_ASSERT_EQUAL(caca_get_canvas_height(cv), 0);
- caca_set_canvas_size(cv, 1, 1);
+ int ret = caca_set_canvas_size(cv, 1, 1);
+ CPPUNIT_ASSERT_EQUAL(ret, 0);
CPPUNIT_ASSERT_EQUAL(caca_get_canvas_width(cv), 1);
CPPUNIT_ASSERT_EQUAL(caca_get_canvas_height(cv), 1);
- caca_set_canvas_size(cv, 1234, 1001);
+ ret = caca_set_canvas_size(cv, 1234, 1001);
+ CPPUNIT_ASSERT_EQUAL(ret, 0);
CPPUNIT_ASSERT_EQUAL(caca_get_canvas_width(cv), 1234);
CPPUNIT_ASSERT_EQUAL(caca_get_canvas_height(cv), 1001);
- caca_set_canvas_size(cv, 0, 0);
+ ret = caca_set_canvas_size(cv, 0, 0);
+ CPPUNIT_ASSERT_EQUAL(ret, 0);
CPPUNIT_ASSERT_EQUAL(caca_get_canvas_width(cv), 0);
CPPUNIT_ASSERT_EQUAL(caca_get_canvas_height(cv), 0);
+ CPPUNIT_ASSERT_EQUAL(-1, caca_set_canvas_size(cv, -1, 50));
+ CPPUNIT_ASSERT_EQUAL(-1, caca_set_canvas_size(cv, 50, -1));
+ CPPUNIT_ASSERT_EQUAL(-1, caca_set_canvas_size(cv, -1, -1));
+ CPPUNIT_ASSERT_EQUAL(-1, caca_set_canvas_size(cv, INT_MAX / 2, 3));
+ CPPUNIT_ASSERT_EQUAL(-1, caca_set_canvas_size(cv, 3, INT_MAX / 2));
+ CPPUNIT_ASSERT_EQUAL(-1, caca_set_canvas_size(cv, INT_MAX / 2, INT_MAX / 2));
+ CPPUNIT_ASSERT_EQUAL(0, caca_set_canvas_size(cv, 0, 0));
+
caca_free_canvas(cv);
}
Index: libcaca-da28e9684ef445ac8d42745644336b8a75c01855/tools/makefont.c
===================================================================
--- libcaca-da28e9684ef445ac8d42745644336b8a75c01855.orig/tools/makefont.c
+++ libcaca-da28e9684ef445ac8d42745644336b8a75c01855/tools/makefont.c
@@ -40,7 +40,8 @@
* and the UTF-8 glyphs necessary for canvas rotation and mirroring. */
static unsigned int const blocklist[] =
{
- 0x0000, 0x0080, /* Basic latin: A, B, C, a, b, c */
+ 0x0020, 0x0080, /* Basic latin: A, B, C, a, b, c */
+#if 0
0x0080, 0x0100, /* Latin-1 Supplement: Ä, Ç, å, ß */
0x0100, 0x0180, /* Latin Extended-A: Ā č Ō œ */
0x0180, 0x0250, /* Latin Extended-B: Ǝ Ƹ */
@@ -63,6 +64,7 @@ static unsigned int const blocklist[] =
0x30a0, 0x3100, /* Katakana: ロ ル */
0xff00, 0xfff0, /* Halfwidth and Fullwidth Forms: , , , , , */
0x10400, 0x10450, /* Deseret: 𐐒 𐐋 */
+#endif
0, 0
};
@@ -105,10 +107,10 @@ int main(int argc, char *argv[])
if(argc != 5)
{
- fprintf(stderr, "%s: wrong argument count\n", argv[0]);
- fprintf(stderr, "usage: %s <prefix> <font> <dpi> <bpp>\n", argv[0]);
- fprintf(stderr, "eg: %s monospace9 \"Monospace 9\" 96 4\n", argv[0]);
- return -1;
+ fprintf(stderr, "%s: wrong argument count\n", argv[0]);
+ fprintf(stderr, "usage: %s <prefix> <font> <dpi> <bpp>\n", argv[0]);
+ fprintf(stderr, "eg: %s monospace9 \"Monospace 9\" 96 4\n", argv[0]);
+ return -1;
}
prefix = argv[1];
@@ -118,8 +120,8 @@ int main(int argc, char *argv[])
if(dpi == 0 || (bpp != 1 && bpp != 2 && bpp != 4 && bpp != 8))
{
- fprintf(stderr, "%s: invalid argument\n", argv[0]);
- return -1;
+ fprintf(stderr, "%s: invalid argument\n", argv[0]);
+ return -1;
}
fprintf(stderr, "Font \"%s\", %i dpi, %i bpp\n", font, dpi, bpp);
@@ -132,9 +134,9 @@ int main(int argc, char *argv[])
l = pango_layout_new(cx);
if(!l)
{
- fprintf(stderr, "%s: unable to initialise pango\n", argv[0]);
- g_object_unref(cx);
- return -1;
+ fprintf(stderr, "%s: unable to initialise pango\n", argv[0]);
+ g_object_unref(cx);
+ return -1;
}
fd = pango_font_description_from_string(font);
@@ -164,11 +166,11 @@ int main(int argc, char *argv[])
fullglyphs = 0;
for(b = 0; blocklist[b + 1]; b += 2)
{
- blocks++;
- glyphs += blocklist[b + 1] - blocklist[b];
- for(i = blocklist[b]; i < blocklist[b + 1]; i++)
- if(caca_utf32_is_fullwidth(i))
- fullglyphs++;
+ blocks++;
+ glyphs += blocklist[b + 1] - blocklist[b];
+ for(i = blocklist[b]; i < blocklist[b + 1]; i++)
+ if(caca_utf32_is_fullwidth(i))
+ fullglyphs++;
}
control_size = 28 + 12 * blocks + 8 * glyphs;
@@ -180,16 +182,16 @@ int main(int argc, char *argv[])
/* Let's go! */
printf("/* libcaca font file\n");
printf(" * \"%s\": %i dpi, %i bpp, %ix%i/%ix%i glyphs\n",
- font, dpi, bpp, stdwidth, height, fullwidth, height);
+ font, dpi, bpp, stdwidth, height, fullwidth, height);
printf(" * Automatically generated by tools/makefont.c:\n");
printf(" * tools/makefont %s \"%s\" %i %i\n", prefix, font, dpi, bpp);
printf(" */\n");
printf("\n");
printf("static size_t const %s_size = %i;\n",
- prefix, 4 + control_size + data_size);
+ prefix, 4 + control_size + data_size);
printf("static uint8_t const %s_data[%i] =\n",
- prefix, 4 + control_size + data_size);
+ prefix, 4 + control_size + data_size);
printf("{\n");
printf("/* file: */\n");
@@ -217,10 +219,10 @@ int main(int argc, char *argv[])
n = 0;
for(b = 0; blocklist[b + 1]; b += 2)
{
- printf_u32("%s", blocklist[b]);
- printf_u32("%s", blocklist[b + 1]);
- printf_u32("%s\n", n);
- n += blocklist[b + 1] - blocklist[b];
+ printf_u32("%s", blocklist[b]);
+ printf_u32("%s", blocklist[b + 1]);
+ printf_u32("%s\n", n);
+ n += blocklist[b + 1] - blocklist[b];
}
printf("\n");
@@ -228,81 +230,81 @@ int main(int argc, char *argv[])
current_offset = n = 0;
for(b = 0; blocklist[b + 1]; b += 2)
{
- for(i = blocklist[b]; i < blocklist[b + 1]; i++)
- {
- int x, y, bytes, current_width = stdwidth;
- unsigned int k, current_size = stdsize;
-
- if(caca_utf32_is_fullwidth(i))
- {
- current_width = fullwidth;
- current_size = fullsize;
- }
- gtab[n].unicode = i;
- bytes = caca_utf32_to_utf8(gtab[n].buf, gtab[n].unicode);
- gtab[n].buf[bytes] = '\0';
-
- /* Render glyph on a bitmap */
- pango_layout_set_text(l, gtab[n].buf, -1);
- memset(img.buffer, 0, img.pitch * height);
- pango_ft2_render_layout(&img, l, 0, 0);
-
- /* Fix glyphs that we know how to handle better */
- fix_glyph(&img, gtab[n].unicode, current_width, height);
-
- /* Write bitmap as an escaped C string */
- memset(glyph_data + current_offset, 0, current_size);
- k = 0;
- for(y = 0; y < height; y++)
- {
- for(x = 0; x < current_width; x++)
- {
- uint8_t pixel = img.buffer[y * img.pitch + x];
-
- pixel >>= (8 - bpp);
- glyph_data[current_offset + k / 8]
- |= pixel << (8 - bpp - (k % 8));
- k += bpp;
- }
- }
-
- /* Check whether this is the same glyph as another one. Please
- * don't bullshit me about sorting, hashing and stuff like that,
- * our data is small enough for this to work. */
- for(k = 0; k < n; k++)
- {
- if(gtab[k].data_size != current_size)
- continue;
+ for(i = blocklist[b]; i < blocklist[b + 1]; i++)
+ {
+ int x, y, bytes, current_width = stdwidth;
+ unsigned int k, current_size = stdsize;
+
+ if(caca_utf32_is_fullwidth(i))
+ {
+ current_width = fullwidth;
+ current_size = fullsize;
+ }
+ gtab[n].unicode = i;
+ bytes = caca_utf32_to_utf8(gtab[n].buf, gtab[n].unicode);
+ gtab[n].buf[bytes] = '\0';
+
+ /* Render glyph on a bitmap */
+ pango_layout_set_text(l, gtab[n].buf, -1);
+ memset(img.buffer, 0, img.pitch * height);
+ pango_ft2_render_layout(&img, l, 0, 0);
+
+ /* Fix glyphs that we know how to handle better */
+ fix_glyph(&img, gtab[n].unicode, current_width, height);
+
+ /* Write bitmap as an escaped C string */
+ memset(glyph_data + current_offset, 0, current_size);
+ k = 0;
+ for(y = 0; y < height; y++)
+ {
+ for(x = 0; x < current_width; x++)
+ {
+ uint8_t pixel = img.buffer[y * img.pitch + x];
+
+ pixel >>= (8 - bpp);
+ glyph_data[current_offset + k / 8]
+ |= pixel << (8 - bpp - (k % 8));
+ k += bpp;
+ }
+ }
+
+ /* Check whether this is the same glyph as another one. Please
+ * don't bullshit me about sorting, hashing and stuff like that,
+ * our data is small enough for this to work. */
+ for(k = 0; k < n; k++)
+ {
+ if(gtab[k].data_size != current_size)
+ continue;
#if 0
- if(!memcmp(glyph_data + gtab[k].data_offset,
- glyph_data + current_offset, current_size))
- break;
+ if(!memcmp(glyph_data + gtab[k].data_offset,
+ glyph_data + current_offset, current_size))
+ break;
#endif
- }
+ }
- gtab[n].data_offset = current_offset;
- gtab[n].data_width = current_width;
- gtab[n].data_size = current_size;
- gtab[n].same_as = k;
+ gtab[n].data_offset = current_offset;
+ gtab[n].data_width = current_width;
+ gtab[n].data_size = current_size;
+ gtab[n].same_as = k;
- if(k == n)
- current_offset += current_size;
+ if(k == n)
+ current_offset += current_size;
- n++;
- }
+ n++;
+ }
}
printf("/* glyph_info: */\n");
n = 0;
for(b = 0; blocklist[b + 1]; b += 2)
{
- for(i = blocklist[b]; i < blocklist[b + 1]; i++)
- {
- printf_u16("%s", gtab[n].data_width);
- printf_u16("%s", height);
- printf_u32("%s\n", gtab[gtab[n].same_as].data_offset);
- n++;
- }
+ for(i = blocklist[b]; i < blocklist[b + 1]; i++)
+ {
+ printf_u16("%s", gtab[n].data_width);
+ printf_u16("%s", height);
+ printf_u32("%s\n", gtab[gtab[n].same_as].data_offset);
+ n++;
+ }
}
printf("\n");
@@ -310,24 +312,38 @@ int main(int argc, char *argv[])
n = 0;
for(b = 0; blocklist[b + 1]; b += 2)
{
- for(i = blocklist[b]; i < blocklist[b + 1]; i++)
- {
- /* Print glyph value in comment */
- printf("/* ");
- printf_unicode(&gtab[n]);
-
- if(gtab[n].same_as == n)
- printf_hex(" */ %s\n",
- glyph_data + gtab[n].data_offset, gtab[n].data_size);
- else
- {
- printf(" is ");
- printf_unicode(&gtab[gtab[n].same_as]);
- printf(" */\n");
- }
+ for(i = blocklist[b]; i < blocklist[b + 1]; i++)
+ {
+ /* Print glyph value in comment */
+ printf("/* ");
+ printf_unicode(&gtab[n]);
+
+ if(gtab[n].same_as == n)
+ {
+ char const *lut = " .:nmW@";
+ printf("\n");
+ for (int y = 0; y < height; ++y)
+ {
+ for (int x = 0; x < gtab[n].data_width; ++x)
+ {
+ int val = glyph_data[gtab[n].data_offset + y * gtab[n].data_width + x];
+ char ch = lut[val * val * 7 / 256 / 256];
+ printf("%c%c", ch, ch);
+ }
+ printf("\n");
+ }
+ //printf_hex(" */ %s\n",
+ // glyph_data + gtab[n].data_offset, gtab[n].data_size);
+ }
+ else
+ {
+ printf(" is ");
+ printf_unicode(&gtab[gtab[n].same_as]);
+ printf(" */\n");
+ }
- n++;
- }
+ n++;
+ }
}
printf("};\n");
@@ -347,74 +363,74 @@ int main(int argc, char *argv[])
*/
static void fix_glyph(FT_Bitmap *i, uint32_t ch,
- unsigned int width, unsigned int height)
+ unsigned int width, unsigned int height)
{
unsigned int x, y;
switch(ch)
{
case 0x00002580: /* ▀ */
- for(y = 0; y < height; y++)
- for(x = 0; x < width; x++)
- i->buffer[x + y * i->pitch] = y < height / 2 ? 0xff : 0x00;
- if(height & 1)
- for(x = 0; x < width; x++)
- i->buffer[x + (height / 2) * i->pitch] = 0x7f;
- break;
+ for(y = 0; y < height; y++)
+ for(x = 0; x < width; x++)
+ i->buffer[x + y * i->pitch] = y < height / 2 ? 0xff : 0x00;
+ if(height & 1)
+ for(x = 0; x < width; x++)
+ i->buffer[x + (height / 2) * i->pitch] = 0x7f;
+ break;
case 0x00002584: /* ▄ */
- for(y = 0; y < height; y++)
- for(x = 0; x < width; x++)
- i->buffer[x + y * i->pitch] = y < height / 2 ? 0x00 : 0xff;
- if(height & 1)
- for(x = 0; x < width; x++)
- i->buffer[x + (height / 2) * i->pitch] = 0x7f;
- break;
+ for(y = 0; y < height; y++)
+ for(x = 0; x < width; x++)
+ i->buffer[x + y * i->pitch] = y < height / 2 ? 0x00 : 0xff;
+ if(height & 1)
+ for(x = 0; x < width; x++)
+ i->buffer[x + (height / 2) * i->pitch] = 0x7f;
+ break;
case 0x0000258c: /* ▌ */
- for(y = 0; y < height; y++)
- for(x = 0; x < width; x++)
- i->buffer[x + y * i->pitch] = x < width / 2 ? 0xff : 0x00;
- if(width & 1)
- for(y = 0; y < height; y++)
- i->buffer[(width / 2) + y * i->pitch] = 0x7f;
- break;
+ for(y = 0; y < height; y++)
+ for(x = 0; x < width; x++)
+ i->buffer[x + y * i->pitch] = x < width / 2 ? 0xff : 0x00;
+ if(width & 1)
+ for(y = 0; y < height; y++)
+ i->buffer[(width / 2) + y * i->pitch] = 0x7f;
+ break;
case 0x00002590: /* ▐ */
- for(y = 0; y < height; y++)
- for(x = 0; x < width; x++)
- i->buffer[x + y * i->pitch] = x < width / 2 ? 0x00 : 0xff;
- if(width & 1)
- for(y = 0; y < height; y++)
- i->buffer[(width / 2) + y * i->pitch] = 0x7f;
- break;
+ for(y = 0; y < height; y++)
+ for(x = 0; x < width; x++)
+ i->buffer[x + y * i->pitch] = x < width / 2 ? 0x00 : 0xff;
+ if(width & 1)
+ for(y = 0; y < height; y++)
+ i->buffer[(width / 2) + y * i->pitch] = 0x7f;
+ break;
case 0x000025a0: /* ■ */
- for(y = 0; y < height; y++)
- for(x = 0; x < width; x++)
- i->buffer[x + y * i->pitch] =
- (y >= height / 4) && (y < 3 * height / 4) ? 0xff : 0x00;
- if(height & 3)
- for(x = 0; x < width; x++) /* FIXME: could be more precise */
- i->buffer[x + (height / 4) * i->pitch] =
- i->buffer[x + (3 * height / 4) * i->pitch] = 0x7f;
- break;
+ for(y = 0; y < height; y++)
+ for(x = 0; x < width; x++)
+ i->buffer[x + y * i->pitch] =
+ (y >= height / 4) && (y < 3 * height / 4) ? 0xff : 0x00;
+ if(height & 3)
+ for(x = 0; x < width; x++) /* FIXME: could be more precise */
+ i->buffer[x + (height / 4) * i->pitch] =
+ i->buffer[x + (3 * height / 4) * i->pitch] = 0x7f;
+ break;
case 0x00002588: /* █ */
- memset(i->buffer, 0xff, height * i->pitch);
- break;
+ memset(i->buffer, 0xff, height * i->pitch);
+ break;
case 0x00002593: /* ▓ */
- for(y = 0; y < height; y++)
- for(x = 0; x < width; x++)
- i->buffer[x + y * i->pitch] =
- ((x + 2 * (y & 1)) & 3) ? 0xff : 0x00;
- break;
+ for(y = 0; y < height; y++)
+ for(x = 0; x < width; x++)
+ i->buffer[x + y * i->pitch] =
+ ((x + 2 * (y & 1)) & 3) ? 0xff : 0x00;
+ break;
case 0x00002592: /* ▒ */
- for(y = 0; y < height; y++)
- for(x = 0; x < width; x++)
- i->buffer[x + y * i->pitch] = ((x + y) & 1) ? 0xff : 0x00;
- break;
+ for(y = 0; y < height; y++)
+ for(x = 0; x < width; x++)
+ i->buffer[x + y * i->pitch] = ((x + y) & 1) ? 0xff : 0x00;
+ break;
case 0x00002591: /* ░ */
- for(y = 0; y < height; y++)
- for(x = 0; x < width; x++)
- i->buffer[x + y * i->pitch] =
- ((x + 2 * (y & 1)) & 3) ? 0x00 : 0xff;
- break;
+ for(y = 0; y < height; y++)
+ for(x = 0; x < width; x++)
+ i->buffer[x + y * i->pitch] =
+ ((x + 2 * (y & 1)) & 3) ? 0x00 : 0xff;
+ break;
}
}
@@ -425,9 +441,9 @@ static int printf_unicode(struct glyph *
wr += printf("U+%.04X: \"", g->unicode);
if(g->unicode < 0x20 || (g->unicode >= 0x7f && g->unicode <= 0xa0))
- wr += printf("\\x%.02x\"", g->unicode);
+ wr += printf("\\x%.02x\"", g->unicode);
else
- wr += printf("%s\"", g->buf);
+ wr += printf("%s\"", g->buf);
return wr;
}
@@ -450,7 +466,7 @@ static int printf_hex(char const *fmt, u
char *parser = buf;
while(bytes--)
- parser += sprintf(parser, "%i,", (unsigned int)*data++);
+ parser += sprintf(parser, "%i,", (unsigned int)*data++);
parser[0] = '\0';
return printf(fmt, buf);

View File

@ -1,8 +1,8 @@
Index: libcaca-0.99.beta19/caca/driver/ncurses.c
Index: libcaca-0.99.beta20/caca/driver/ncurses.c
===================================================================
--- libcaca-0.99.beta19.orig/caca/driver/ncurses.c
+++ libcaca-0.99.beta19/caca/driver/ncurses.c
@@ -262,11 +262,7 @@ static int ncurses_init_graphics(caca_di
--- libcaca-0.99.beta20.orig/caca/driver/ncurses.c
+++ libcaca-0.99.beta20/caca/driver/ncurses.c
@@ -268,11 +268,7 @@ static int ncurses_init_graphics(caca_di
mouseinterval(-1); /* No click emulation */
/* Set the escape delay to a ridiculously low value */

View File

@ -2,7 +2,7 @@ Index: configure.ac
===================================================================
--- configure.ac.orig
+++ configure.ac
@@ -475,14 +475,17 @@ ac_cv_my_have_ruby_minitest="no"
@@ -489,14 +489,17 @@ ac_cv_my_have_ruby_minitest="no"
if test "${enable_ruby}" != "no"; then
AC_PATH_PROG(RUBY, ruby, no)
if test "${RUBY}" != "no"; then

View File

@ -1,27 +0,0 @@
Author: Josef Möllers <jmoellers@suse.de>
Index: libcaca-da28e9684ef445ac8d42745644336b8a75c01855/src/common-image.h
===================================================================
--- libcaca-da28e9684ef445ac8d42745644336b8a75c01855.orig/src/common-image.h
+++ libcaca-da28e9684ef445ac8d42745644336b8a75c01855/src/common-image.h
@@ -13,7 +13,7 @@
struct image
{
char *pixels;
- unsigned int w, h;
+ size_t w, h;
struct caca_dither *dither;
void *priv;
};
Index: libcaca-da28e9684ef445ac8d42745644336b8a75c01855/caca/dither.c
===================================================================
--- libcaca-da28e9684ef445ac8d42745644336b8a75c01855.orig/caca/dither.c
+++ libcaca-da28e9684ef445ac8d42745644336b8a75c01855/caca/dither.c
@@ -116,7 +116,7 @@ enum color_mode
struct caca_dither
{
int bpp, has_palette, has_alpha;
- int w, h, pitch;
+ size_t w, h, pitch;
int rmask, gmask, bmask, amask;
int rright, gright, bright, aright;
int rleft, gleft, bleft, aleft;

View File

@ -1,3 +1,30 @@
-------------------------------------------------------------------
Mon Nov 14 15:32:39 UTC 2022 - Valentin Lefebvre <valentin.lefebvre@suse.com>
- add patch [libcaca-autoconf-2.69.patch]
* Don't force autoconf to be at version 2.71
-------------------------------------------------------------------
Mon Nov 14 14:07:25 UTC 2022 - Valentin Lefebvre <valentin.lefebvre@suse.com>
- Upgrade to 0.99.beta20
* IPv6 support in cacaserver
* fixed a bug from 2004 that caused PDF documentation generation to fail
* memory allocation functions are now more robust
* numerous fixes for memory leaks and invalid memory accesses:
* CVE-2021-30498
* CVE-2021-30499
* CVE-2021-3410
* CVE-2018-20546
* CVE-2018-20547
* CVE-2018-20545
* CVE-2018-20548
* CVE-2018-20549
- Dropped upstream fixed patches
* libcaca-bsc1182731-prevent-overflow.patch
* libcaca-variable-type.patch
* Bug1120502-add_cast_to_prevent_overflow.patch
-------------------------------------------------------------------
Mon Mar 14 13:36:16 UTC 2022 - Josef Möllers <josef.moellers@suse.com>

View File

@ -16,16 +16,14 @@
#
#
%define _rev da28e9684ef445ac8d42745644336b8a75c01855
Name: libcaca
Version: 0.99.beta19.git20171003
Version: 0.99.beta20
Release: 0
Summary: Library for Colour ASCII Art, text mode graphics
License: WTFPL
Group: Development/Languages/C and C++
URL: http://caca.zoy.org
Source0: https://github.com/cacalabs/%{name}/archive/%{_rev}.tar.gz#/%{name}-%{version}.tar.gz
Source0: https://github.com/cacalabs/%{name}/releases/download/v%{version}/%{name}-%{version}.tar.gz
Source1: baselibs.conf
Patch1: libcaca-0.99-texbuild.patch
Patch2: libcaca-X11_test.patch
@ -34,13 +32,11 @@ Patch5: libcaca-ruby_vendor_install.patch
Patch7: libcaca-0.99.beta16-missing-GLU.patch
Patch9: caca-no-build-date.patch
Patch10: libcaca-ncurses6.patch
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
# PATCH-FIX-UPSTREAM correctly-handle-zero-width-or-height-images.patch bsc#1197028
Patch100: bsc1197028-correctly-handle-zero-width-or-height-images.patch
Patch101: libcaca-autoconf-2.69.patch
BuildRequires: doxygen
BuildRequires: fdupes
BuildRequires: freeglut-devel
@ -135,7 +131,7 @@ that shows the libcaca rendering features such as line and ellipses
drawing, triangle filling and sprite blitting.
%prep
%setup -q -n %{name}-%{_rev}
%setup -q
%patch2
%patch4
%patch5
@ -143,12 +139,10 @@ drawing, triangle filling and sprite blitting.
%patch9
%patch1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch99 -p1
%patch100 -p1
%patch101 -p1
RUBY="ruby-`echo %{rb_ver} | sed 's|\.[^\.]*$||'`"
find . -type f -exec sed -i "s|ruby-1.9|$RUBY|" \{\} \;
pushd python
@ -189,7 +183,7 @@ find %{buildroot} -type f -name "*.la" -delete -print
%postun -n libcaca0-plugins -p /sbin/ldconfig
%files -n libcaca0
%doc AUTHORS ChangeLog NEWS NOTES README THANKS
%doc AUTHORS NEWS NOTES README THANKS
%license COPYING
%{_libdir}/*.so.*