Просмотр исходного кода

* apt-pkg/contrib/sha1.cc:
- fix illegally casts of on-stack buffer to a type requiring more
alignment than it has resulting in segfaults on sparc (Closes: #634696)

The problem is how sha1.cc codes the SHA1 transform, it illegally
casts the on-stack workspace buffer to a type requiring more
alignment than 'workspace' is actually declared to have.

This only shows up recently because gcc-4.6 now does a really
aggressive optimization where it gets rid of the workspace
buffer entirely and just accesses 'buffer' directly, and assumes
it has the necessary alignment for 32-bit loads (which it
doesn't).

David Miller лет назад: 15
Родитель
Сommit
1edc38abff
2 измененных файлов с 11 добавлено и 3 удалено
  1. 2 3
      apt-pkg/contrib/sha1.cc
  2. 9 0
      debian/changelog

+ 2 - 3
apt-pkg/contrib/sha1.cc

@@ -74,10 +74,9 @@ static void SHA1Transform(uint32_t state[5],uint8_t const buffer[64])
       uint32_t l[16];
    }
    CHAR64LONG16;
-   CHAR64LONG16 *block;
+   CHAR64LONG16 workspace, *block;
 
-   uint8_t workspace[64];
-   block = (CHAR64LONG16 *)workspace;
+   block = &workspace;
    memcpy(block,buffer,sizeof(workspace));
 
    /* Copy context->state[] to working vars */

+ 9 - 0
debian/changelog

@@ -1,3 +1,12 @@
+apt (0.8.15.4) unstable; urgency=low
+
+  [ David Miller ]
+  * apt-pkg/contrib/sha1.cc:
+    - fix illegally casts of on-stack buffer to a type requiring more
+      alignment than it has resulting in segfaults on sparc (Closes: #634696)
+
+ -- David Kalnischkies <kalnischkies@gmail.com>  Tue, 26 Jul 2011 08:26:53 +0200
+
 apt (0.8.15.3) unstable; urgency=low
 
   [ Michael Vogt ]