[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#367417: `apt-get update' causes unaligned accesses



Package: apt
Version: 0.6.44
Tags: patch

The current version of `apt' causes unaligned accesses whenever
running "apt-get update".  On ia64 Linux, this typically shows up as
messages of the form:

 http(22944): unaligned access to 0x60000000000062dd, ip=0x20000000000a6e01

The problem comes from transform_sha256, which assumes that the input
data is 32-bit aligned (or that misaligned access are "cheap").  The
patch below fixes the problem by open-coding the ntohl() call and
combining it with a byte-by-byte load of the 32-bit word.

	--david

--- apt-0.6.44/apt-pkg/contrib/sha256.cc	2006-03-29 18:01:29.000000000 -0700
+++ apt-0.6.44-fixed/apt-pkg/contrib/sha256.cc	2006-05-15 13:49:00.000000000 -0600
@@ -61,7 +61,10 @@
 
 static inline void LOAD_OP(int I, u32 *W, const u8 *input)
 {
-        W[I] = ntohl( ((u32*)(input))[I] );
+	W[I] = (  ((u32) input[I + 0] << 24)
+		| ((u32) input[I + 1] << 16)
+		| ((u32) input[I + 2] << 8)
+		| ((u32) input[I + 3]));
 }
 
 static inline void BLEND_OP(int I, u32 *W)



Reply to: