mpatch: attempt to handle unpack alignment issues on Solaris
authormpm@selenic.com
Thu, 16 Jun 2005 22:54:37 -0800
changeset 384 a29decbf7475
parent 383 4862a134e2c2
child 385 e9e1efd5291c
mpatch: attempt to handle unpack alignment issues on Solaris -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 mpatch: attempt to handle unpack alignment issues on Solaris manifest hash: e185dc380bab61cf11a9973ee3ddd2e904e56299 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCsnOtywK+sNU5EO8RAlzQAJ9YIhbL8BJjT+J/pOiQVES2wsF0igCgnFRl ok5f8i8GbNk77sRbpsGnUF0= =m0Zh -----END PGP SIGNATURE-----
mercurial/mpatch.c
--- a/mercurial/mpatch.c	Thu Jun 16 22:32:55 2005 -0800
+++ b/mercurial/mpatch.c	Thu Jun 16 22:54:37 2005 -0800
@@ -195,15 +195,17 @@
 	struct flist *l;
 	struct frag *lt;
 	char *end = bin + len;
+	char decode[12]; /* for dealing with alignment issues */
 
 	/* assume worst case size, we won't have many of these lists */
 	l = lalloc(len / 12);
 	lt = l->tail;
 
 	while (bin < end) {
-		lt->start = ntohl(*(uint32_t *)bin);
-		lt->end = ntohl(*(uint32_t *)(bin + 4));
-		lt->len = ntohl(*(uint32_t *)(bin + 8));
+		memcpy(decode, bin, 12);
+		lt->start = ntohl(*(uint32_t *)decode);
+		lt->end = ntohl(*(uint32_t *)(decode + 4));
+		lt->len = ntohl(*(uint32_t *)(decode + 8));
 		lt->data = bin + 12;
 		bin += 12 + lt->len;
 		lt++;