pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/graphics/babl Fix alignement related crashes
details: https://anonhg.NetBSD.org/pkgsrc/rev/34bd49558ae9
branches: trunk
changeset: 307073:34bd49558ae9
user: martin <martin%pkgsrc.org@localhost>
date: Tue May 01 20:26:38 2018 +0000
description:
Fix alignement related crashes
diffstat:
graphics/babl/Makefile | 3 +-
graphics/babl/distinfo | 3 +-
graphics/babl/patches/patch-extensions_gggl.c | 513 ++++++++++++++++++++++++++
3 files changed, 517 insertions(+), 2 deletions(-)
diffs (truncated from 541 to 300 lines):
diff -r a2673f12851b -r 34bd49558ae9 graphics/babl/Makefile
--- a/graphics/babl/Makefile Tue May 01 18:35:56 2018 +0000
+++ b/graphics/babl/Makefile Tue May 01 20:26:38 2018 +0000
@@ -1,6 +1,7 @@
-# $NetBSD: Makefile,v 1.17 2018/04/29 21:28:58 ryoon Exp $
+# $NetBSD: Makefile,v 1.18 2018/05/01 20:26:38 martin Exp $
DISTNAME= babl-0.1.46
+PKGREVISION= 1
CATEGORIES= graphics
MASTER_SITES= http://download.gimp.org/pub/babl/0.1/
EXTRACT_SUFX= .tar.bz2
diff -r a2673f12851b -r 34bd49558ae9 graphics/babl/distinfo
--- a/graphics/babl/distinfo Tue May 01 18:35:56 2018 +0000
+++ b/graphics/babl/distinfo Tue May 01 20:26:38 2018 +0000
@@ -1,6 +1,7 @@
-$NetBSD: distinfo,v 1.15 2018/04/29 21:28:58 ryoon Exp $
+$NetBSD: distinfo,v 1.16 2018/05/01 20:26:38 martin Exp $
SHA1 (babl-0.1.46.tar.bz2) = 33c77797bcabc1064b28f7f953db813468424147
RMD160 (babl-0.1.46.tar.bz2) = 9c6a2fe80ae5d68b40c55ef0ed38d0436edd02c0
SHA512 (babl-0.1.46.tar.bz2) = a62d78d49565cfb5c3187353f31d7793156ae318e2a29b7430ca08272ea98b9101afb602d73c5cc87bc9f20a4469bc08bf8c6c197529260ae0e41d183f300648
Size (babl-0.1.46.tar.bz2) = 653887 bytes
+SHA1 (patch-extensions_gggl.c) = 308fa13ab4dfc3f259f1c220d9619d24e8459716
diff -r a2673f12851b -r 34bd49558ae9 graphics/babl/patches/patch-extensions_gggl.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/babl/patches/patch-extensions_gggl.c Tue May 01 20:26:38 2018 +0000
@@ -0,0 +1,513 @@
+$NetBSD: patch-extensions_gggl.c,v 1.1 2018/05/01 20:26:38 martin Exp $
+
+Patch also submitted upstream:
+ https://bugzilla.gnome.org/show_bug.cgi?id=795726
+
+Fixes crashes on alignment critical architectures.
+
+--- extensions/gggl.c.orig 2018-04-07 16:38:23.000000000 +0200
++++ extensions/gggl.c 2018-05-01 22:09:47.319795395 +0200
+@@ -56,12 +56,15 @@ conv_F_8 (const Babl *conversion,unsigne
+
+ while (n--)
+ {
+- float f = ((*(float *) src));
+- int uval = lrint (f * 255.0);
++ float f;
++ int uval;
++
++ memcpy(&f, src, sizeof(f));
++ uval = lrint (f * 255.0);
+
+ if (uval < 0) uval = 0;
+ if (uval > 255) uval = 255;
+- *(unsigned char *) dst = uval;
++ *dst = uval;
+
+ dst += 1;
+ src += 4;
+@@ -72,21 +75,26 @@ static void
+ conv_F_16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
+ {
+ long n = samples;
++ unsigned short v;
+
+ while (n--)
+ {
+- float f = ((*(float *) src));
++ float f;
++ memcpy(&f, src, sizeof(f));
+ if (f < 0.0)
+ {
+- *(unsigned short *) dst = 0;
++ v = 0;
++ memcpy(dst, &v, sizeof(v));
+ }
+ else if (f > 1.0)
+ {
+- *(unsigned short *) dst = 65535;
++ v = 65535;
++ memcpy(dst, &v, sizeof(v));
+ }
+ else
+ {
+- *(unsigned short *) dst = lrint (f * 65535.0);
++ v = lrint (f * 65535.0);
++ memcpy(dst, &v, sizeof(v));
+ }
+ dst += 2;
+ src += 4;
+@@ -100,7 +108,9 @@ conv_8_F (const Babl *conversion,unsigne
+
+ while (n--)
+ {
+- (*(float *) dst) = ((*(unsigned char *) src) / 255.0);
++ float v;
++ v = *src / 255.0;
++ memcpy(dst, &v, sizeof(v));
+ dst += 4;
+ src += 1;
+ }
+@@ -113,7 +123,8 @@ conv_16_F (const Babl *conversion,unsign
+
+ while (n--)
+ {
+- (*(float *) dst) = *(unsigned short *) src / 65535.0;
++ float v = *src / 65535.0;
++ memcpy(dst, &v, sizeof(v));
+ dst += 4;
+ src += 2;
+ }
+@@ -130,13 +141,18 @@ conv_rgbaF_rgb8 (const Babl *conversion,
+
+ for (c = 0; c < 3; c++)
+ {
+- int val = rint ((*(float *) src) * 255.0);
++ float v;
++ int val;
++
++ memcpy(&v, src, sizeof(v));
++ val = rint (v * 255.0);
++
+ if (val < 0)
+- *(unsigned char *) dst = 0;
++ *dst = 0;
+ else if (val > 255)
+- *(unsigned char *) dst = 255;
++ *dst = 255;
+ else
+- *(unsigned char *) dst = val;
++ *dst = val;
+ dst += 1;
+ src += 4;
+ }
+@@ -151,7 +167,11 @@ conv_F_D (const Babl *conversion,unsigne
+
+ while (n--)
+ {
+- *(double *) dst = ((*(float *) src));
++ float sv;
++ double dv;
++ memcpy(&sv, src, sizeof(sv));
++ dv = (float)sv;
++ memcpy(dst, &dv, sizeof(dv));
+ dst += 8;
+ src += 4;
+ }
+@@ -164,7 +184,11 @@ conv_D_F (const Babl *conversion,unsigne
+
+ while (n--)
+ {
+- *(float *) dst = ((*(double *) src));
++ float dv;
++ double sv;
++ memcpy(&sv, src, sizeof(sv));
++ dv = sv;
++ memcpy(dst, &dv, sizeof(dv));
+ dst += 4;
+ src += 8;
+ }
+@@ -178,7 +202,9 @@ conv_16_8 (const Babl *conversion,unsign
+ while (n--)
+ {
+ #define div_257(a) ((((a)+128)-(((a)+128)>>8))>>8)
+- (*(unsigned char *) dst) = div_257 (*(unsigned short *) src);
++ unsigned short sv;
++ memcpy(&sv, src, sizeof(sv));
++ *dst = div_257 (sv);
+ dst += 1;
+ src += 2;
+ }
+@@ -191,7 +217,8 @@ conv_8_16 (const Babl *conversion,unsign
+
+ while (n--)
+ {
+- (*(unsigned short *) dst) = ((*(unsigned char *) src) << 8) | *src;
++ unsigned short dv = (*src << 8) | *src;
++ memcpy(dst, &dv, sizeof(dv));
+ dst += 2;
+ src += 1;
+ }
+@@ -353,12 +380,14 @@ conv_gaF_gAF (const Babl *conversion,uns
+
+ while (n--)
+ {
+- float alpha = (*(float *) (src + 4));
+-
+- *(float *) dst = ((*(float *) src) * alpha);
++ float alpha, sv;
++ memcpy(&alpha, src + 4, sizeof(alpha));
++ memcpy(&sv, src, sizeof(sv));
++ sv *= alpha;
++ memcpy(dst, &sv, sizeof(sv));
+ dst += 4;
+ src += 4;
+- *(float *) dst = alpha;
++ memcpy(dst, &alpha, sizeof(alpha));
+ dst += 4;
+ src += 4;
+ }
+@@ -371,15 +400,19 @@ conv_gAF_gaF (const Babl *conversion,uns
+
+ while (n--)
+ {
+- float alpha = (*(float *) (src + 4));
++ float alpha, sv, dv;
++ memcpy(&alpha, src+4, sizeof(alpha));
+
+ if (alpha == 0.0f)
+- *(float *) dst = 0.0f;
+- else
+- *(float *) dst = ((*(float *) src) / alpha);
++ dv = 0.0f;
++ else {
++ memcpy(&sv, src, sizeof(sv));
++ dv = sv / alpha;
++ }
++ memcpy(dst, &dv, sizeof(dv));
+ dst += 4;
+ src += 4;
+- *(float *) dst = alpha;
++ memcpy(dst, &alpha, sizeof(alpha));
+ dst += 4;
+ src += 4;
+ }
+@@ -394,16 +427,9 @@ conv_rgbaF_rgbF (const Babl *conversion,
+
+ while (n--)
+ {
+- *(uint32_t *) dst = (*(uint32_t *) src);
+- dst += 4;
+- src += 4;
+- *(uint32_t *) dst = (*(uint32_t *) src);
+- dst += 4;
+- src += 4;
+- *(uint32_t *) dst = (*(uint32_t *) src);
+- dst += 4;
+- src += 4;
+- src += 4;
++ memcpy(dst, src, 4*3);
++ dst += 4*3;
++ src += 4*4;
+ }
+ }
+
+@@ -411,15 +437,12 @@ static void
+ conv_rgbF_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
+ {
+ long n = samples;
+- float *fsrc = (void*) src;
+- float *fdst = (void*) dst;
++ float one = 1.0f;
+
+ while (n--)
+ {
+- *fdst++ = *fsrc++;
+- *fdst++ = *fsrc++;
+- *fdst++ = *fsrc++;
+- *fdst++ = 1.0f;
++ memcpy(dst, src, sizeof(float)*3);
++ memcpy(dst, &one, sizeof(one));
+ }
+ }
+
+@@ -433,7 +456,7 @@ conv_gaF_gF (const Babl *conversion,unsi
+
+ while (n--)
+ {
+- *(int *) dst = (*(int *) src);
++ memcpy(dst, src, 4);
+ dst += 4;
+ src += 4;
+ src += 4;
+@@ -444,13 +467,14 @@ static void
+ conv_gF_gaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
+ {
+ long n = samples;
++ float one = 1.0f;
+
+ while (n--)
+ {
+- *(float *) dst = (*(float *) src);
++ memcpy(dst, src, sizeof(float));
+ dst += 4;
+ src += 4;
+- *(float *) dst = 1.0;
++ memcpy(dst, &one, sizeof(one));
+ dst += 4;
+ }
+ }
+@@ -472,7 +496,7 @@ conv_gF_rgbF (const Babl *conversion,uns
+
+ for (c = 0; c < 3; c++)
+ {
+- (*(float *) dst) = (*(float *) src);
++ memcpy(dst, src, 4);
+ dst += 4;
+ }
+ src += 4;
+@@ -521,11 +545,11 @@ conv_gaF_rgbaF (const Babl *conversion,u
+
+ for (c = 0; c < 3; c++)
+ {
Home |
Main Index |
Thread Index |
Old Index