Differences

This shows you the differences between two versions of the page.

Link to this comparison view

people:solar:software:public-domain-source-code:md5 [2016/06/15 13:17]
solar Explicitly cast 8-bit portions of MD5_u32plus values to unsigned char to avoid warnings from clang, as reported by Werner LEMBERG along with a suggested fix
people:solar:software:public-domain-source-code:md5 [2016/06/15 16:11] (current)
solar Documented in a comment a possible C strict aliasing rules violation if the caller's data buffer has effective type that cannot be aliased by MD5_u32plus
Line 81: Line 81:
  
 /* /*
- * SET reads 4 input bytes in little-endian byte order and stores them + * SET reads 4 input bytes in little-endian byte order and stores them in a 
- ​* ​in a properly aligned word in host byte order.+ ​* ​properly aligned word in host byte order.
  *  *
- * The check for little-endian architectures that tolerate unaligned + * The check for little-endian architectures that tolerate unaligned ​memory 
- ​* ​memory ​accesses is just an optimization. ​ Nothing will break if it + * accesses is just an optimization. ​ Nothing will break if it fails to detect 
- ​* ​doesn't work.+ ​* ​a suitable architecture. 
 + * 
 + * Unfortunately,​ this optimization may be a C strict aliasing rules violation 
 + * if the caller's data buffer has effective type that cannot be aliased by 
 + * MD5_u32plus. ​ In practice, this problem may occur if these MD5 routines are 
 + * inlined into a calling function, or with future and dangerously advanced 
 + * link-time optimizations. ​ For the time being, keeping these MD5 routines in 
 + * their own translation unit avoids the problem.
  */  */
 #if defined(__i386__) || defined(__x86_64__) || defined(__vax__) #if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
Line 105: Line 112:
  
 /* /*
- * This processes one or more 64-byte data blocks, but does NOT update + * This processes one or more 64-byte data blocks, but does NOT update the bit 
- ​* ​the bit counters. ​ There are no alignment requirements.+ ​* ​counters. ​ There are no alignment requirements.
  */  */
 static const void *body(MD5_CTX *ctx, const void *data, unsigned long size) static const void *body(MD5_CTX *ctx, const void *data, unsigned long size)
people/solar/software/public-domain-source-code/md5.txt · Last modified: 2016/06/15 16:11 by solar
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate to DokuWiki Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki Powered by OpenVZ Powered by Openwall GNU/*/Linux