[asterisk-commits] rmudgett: trunk r371952 - /trunk/include/asterisk/md5.h

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Aug 29 17:48:11 CDT 2012


Author: rmudgett
Date: Wed Aug 29 17:48:08 2012
New Revision: 371952

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=371952
Log:
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

Modified:
    trunk/include/asterisk/md5.h

Modified: trunk/include/asterisk/md5.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/md5.h?view=diff&rev=371952&r1=371951&r2=371952
==============================================================================
--- trunk/include/asterisk/md5.h (original)
+++ trunk/include/asterisk/md5.h Wed Aug 29 17:48:08 2012
@@ -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);




More information about the asterisk-commits mailing list