From f075e7631fe8c989da09e9566338fe25bd76c479 Mon Sep 17 00:00:00 2001
From: Richard Mudgett <rmudgett@digium.com>
Date: Wed, 29 Aug 2012 22:48:08 +0000
Subject: [PATCH] Ensure alignment of in[] field in MD5Context struct.

The struct MD5Context character buffer is cast to an int32_t* without
making sure that said buffer is aligned.

Since the buffer follows two uint32_t's, the chance of 'in' being (32
bits) unaligned is nil in practice.  But adding code to ensure that 'in'
stays aligned costs nothing and removes all doubts about the casts being
safe.

(closes issue ASTERISK-20241)
Reported by: Walter Doekes
Patches:
      tmp.diff (license #5674) patch uploaded by Walter Doekes


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@371952 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 include/asterisk/md5.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/asterisk/md5.h b/include/asterisk/md5.h
index 714267da66..301429239c 100644
--- a/include/asterisk/md5.h
+++ b/include/asterisk/md5.h
@@ -26,7 +26,8 @@
 struct MD5Context {
 	uint32_t buf[4];
 	uint32_t bits[2];
-	unsigned char in[64];
+	/*! Align because we cast this buffer to uint32s */
+	unsigned char in[64] __attribute__((aligned(__alignof__(uint32_t))));
 };
 
 void MD5Init(struct MD5Context *context);
-- 
GitLab