[Pkg-gnutls-maint] Bug#499542: libgcrypt11_1.4.3-1(sparc/experimental): FTBFS: test failure

Werner Koch wk at gnupg.org
Sat Sep 20 09:16:47 UTC 2008


On Sat, 20 Sep 2008 09:12, ametzler at downhill.at.eu.org said:

> Program received signal SIGBUS, Bus error.
> 0xf7f00af8 in finalize (hd=0x2cec8) at hmac256.c:279
> 279       X(0);

Interesting:

  #ifdef WORDS_BIGENDIAN
  #define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0)
  #else /* little endian */
  #define X(a) do { *p++ = hd->h##a >> 24; *p++ = hd->h##a >> 16;	 \
		  *p++ = hd->h##a >> 8; *p++ = hd->h##a; } while(0)
  #endif

The same code is used for 10 years or so all over the place but
obviously P used to be correctly alliged.  Now this incarnation of the
code has an unaliged P and thus crashes.  Easy to fix:

--- src/hmac256.c       (revision 1342)
+++ src/hmac256.c       (working copy)
@@ -271,10 +271,12 @@
   /* Store the digest into hd->buf.  */
   p = hd->buf;
 #ifdef WORDS_BIGENDIAN
-#define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0)
+#define X(a) do { *p++ = hd->h##a;       *p++ = hd->h##a >> 8;   \
+                 *p++ = hd->h##a >> 16; *p++ = hd->h##a >> 24; } while(0)
 #else /* little endian */
 #define X(a) do { *p++ = hd->h##a >> 24; *p++ = hd->h##a >> 16;         \
                  *p++ = hd->h##a >> 8; *p++ = hd->h##a; } while(0)
+
 #endif
   X(0);
   X(1);



Shalom-Salam,

   Werner


-- 
Linux-Kongress 2008 + Hamburg + October 7-10 + www.linux-kongress.org

   Die Gedanken sind frei.  Auschnahme regelt ein Bundeschgesetz.






More information about the Pkg-gnutls-maint mailing list