Hi Marcelo,

Seeing how this bug was for all intents and purposes introduced by an NMU,
and it's a bug we ought to have fixed for etch, I've prepared a 0-day NMU to
fix it.  The patch is attached; note that this NMU fixes *two*
strict-aliasing errors in io.c, not just the one in the patch provided
earlier.

On its way up to incoming now, hopefully in time for etch.

Thanks,
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
[EMAIL PROTECTED]                                   http://www.debian.org/
diff -u lib3ds-1.2.0/debian/changelog lib3ds-1.2.0/debian/changelog
--- lib3ds-1.2.0/debian/changelog
+++ lib3ds-1.2.0/debian/changelog
@@ -1,3 +1,14 @@
+lib3ds (1.2.0-4.2) unstable; urgency=high
+
+  * Non-maintainer upload.
+  * High-urgency upload for RC bugfix.
+  * Use an explicit union instead of an arbitrary cast between pointer types,
+    to fix a bug when built with gcc-4.1 that causes all floats to be read
+    and written wrong in 3ds files due to strict aliasing rules.
+    Closes: #399761.
+
+ -- Steve Langasek <[EMAIL PROTECTED]>  Fri, 06 Apr 2007 02:12:13 -0700
+
 lib3ds (1.2.0-4.1) unstable; urgency=low
 
   * NMU.
only in patch2:
unchanged:
--- lib3ds-1.2.0.orig/lib3ds/io.c
+++ lib3ds-1.2.0/lib3ds/io.c
@@ -247,16 +247,17 @@
 Lib3dsFloat
 lib3ds_io_read_float(Lib3dsIo *io)
 {
+  union f_and_dw { Lib3dsDword dwval; Lib3dsFloat fval;};
   Lib3dsByte b[4];
-  Lib3dsDword d;
+  union f_and_dw d;
 
   ASSERT(io);
   lib3ds_io_read(io, b, 4);
-  d=((Lib3dsDword)b[3] << 24) |
+  d.dwval=((Lib3dsDword)b[3] << 24) |
     ((Lib3dsDword)b[2] << 16) |
     ((Lib3dsDword)b[1] << 8) |
     ((Lib3dsDword)b[0]);
-  return(*((Lib3dsFloat*)&d));
+  return d.fval;
 }
 
 
@@ -458,15 +459,16 @@
 Lib3dsBool
 lib3ds_io_write_float(Lib3dsIo *io, Lib3dsFloat l)
 {
+  union f_and_dw { Lib3dsDword dwval; Lib3dsFloat fval;};
   Lib3dsByte b[4];
-  Lib3dsDword d;
+  union f_and_dw d;
 
   ASSERT(io);
-  d=*((Lib3dsDword*)&l);
-  b[3]=(Lib3dsByte)(((Lib3dsDword)d & 0xFF000000) >> 24);
-  b[2]=(Lib3dsByte)(((Lib3dsDword)d & 0x00FF0000) >> 16);
-  b[1]=(Lib3dsByte)(((Lib3dsDword)d & 0x0000FF00) >> 8);
-  b[0]=(Lib3dsByte)(((Lib3dsDword)d & 0x000000FF));
+  d.fval=l;
+  b[3]=(Lib3dsByte)((d.dwval & 0xFF000000) >> 24);
+  b[2]=(Lib3dsByte)((d.dwval & 0x00FF0000) >> 16);
+  b[1]=(Lib3dsByte)((d.dwval & 0x0000FF00) >> 8);
+  b[0]=(Lib3dsByte)((d.dwval & 0x000000FF));
   if (lib3ds_io_write(io, b, 4)!=4) {
     return(LIB3DS_FALSE);
   }

Reply via email to