RSS/Atom feed Twitter
Site is read-only, email is disabled

Endianness bug in tiff plugin

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

1 of 1 message available
Toggle history

Please log in to manage your subscriptions.

Endianness bug in tiff plugin Brion Vibber 11 Jul 09:01
Brion Vibber
2004-07-11 09:01:38 UTC (over 20 years ago)

Endianness bug in tiff plugin

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

When loading a CMYK TIFF (and perhaps other funky kinds of TIFF), the tiff plugin uses a fallback mode that fills a buffer using TIFFReadRGBAImage(). This is a uint32 array, and the byte layout of the pixels ends up wrong on a big-endian host such as my PowerBook.

I've posted a test case and patch on bugzilla: http://bugzilla.gnome.org/show_bug.cgi?id=147328

Patch is also attached here; it works on my Mac and doesn't seem to break things on my Linux PC. (HACKING suggests both posting here and bugzilla; I apologize if I'm being overly rude in this.)

The bug affects at least 2.0.x release versions and current CVS.

- -- brion vibber (brion @ pobox.com) -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFA8OXSwRnhpk1wk44RAjtEAJ9zCO+R0NIZuF2nq82kThnKQVWkuQCg04zo nU46gRCBgkWy7FBsFDGc7L4=
=61/D
-----END PGP SIGNATURE-----

Index: tiff.c =================================================================== RCS file: /cvs/gnome/gimp/plug-ins/common/tiff.c,v retrieving revision 1.100
diff -u -r1.100 tiff.c
--- tiff.c 5 Jun 2004 10:27:47 -0000 1.100 +++ tiff.c 11 Jul 2004 06:22:09 -0000 @@ -981,6 +981,12 @@

for (row = 0; row < imageLength; ++row) {
+#if G_BYTE_ORDER != G_LITTLE_ENDIAN + /* Make sure our channels are in the right order */ + uint32 i;
+ for (i = 0; i < imageWidth; i++) + buffer[i + row * imageWidth] = GUINT32_TO_LE (buffer[i + row * imageWidth]); +#endif
gimp_pixel_rgn_set_rect (&(channel[0].pixel_rgn), channel[0].pixels + row * imageWidth * 4, 0, imageLength -row -1, imageWidth, 1);