Recently (with commit of Jan 15 2009) MD5 hash function in
X509_NAME_hash was replaced by SHA1.
However local variable to hold computed hash value is still 16 bytes
(when 20 is required).
This causes stack corruption and segmentation faults on some platforms
(detected on Debian Linux 4.0 amd64)
Following patch fixes this problem.
This patch use symbolic SHA_DIGEST_LENGTH constant, which makes
correspondence between md variable size and used hash function more
noticeable.
Index: crypto/x509/x509_cmp.c
===================================================================
RCS file: /cvs-openssl/openssl/crypto/x509/x509_cmp.c,v
retrieving revision 1.33
diff -u -r1.33 x509_cmp.c
--- crypto/x509/x509_cmp.c 15 Jan 2009 13:22:39 -0000 1.33
+++ crypto/x509/x509_cmp.c 16 Feb 2009 12:56:04 -0000
@@ -201,7 +201,7 @@
unsigned long X509_NAME_hash(X509_NAME *x)
{
unsigned long ret=0;
- unsigned char md[16];
+ unsigned char md[SHA_DIGEST_LENGTH];
/* Make sure X509_NAME structure contains valid cached encoding */
i2d_X509_NAME(x,NULL);