[PATCH 12/42] libcrypt/crypt-md5.c: Fix overflow issues

Joel Sherrill joel.sherrill at oarcorp.com
Mon Mar 23 14:39:10 UTC 2015


---
 cpukit/libcrypt/crypt-md5.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/cpukit/libcrypt/crypt-md5.c b/cpukit/libcrypt/crypt-md5.c
index c60dcf8..78ae0bc 100644
--- a/cpukit/libcrypt/crypt-md5.c
+++ b/cpukit/libcrypt/crypt-md5.c
@@ -133,6 +133,17 @@ crypt_md5_r(const char *pw, const char *salt, struct crypt_data *data)
 
 	p = passwd + strlen(passwd);
 
+#if defined(__rtems__)
+	l = ((long int) final[ 0]<<16) | ((long int) final[ 6]<<8) | final[12];
+	_crypt_to64(p, l, 4); p += 4;
+	l = ((long int) final[ 1]<<16) | ((long int) final[ 7]<<8) | final[13];
+	_crypt_to64(p, l, 4); p += 4;
+	l = ((long int) final[ 2]<<16) | ((long int) final[ 8]<<8) | final[14];
+	_crypt_to64(p, l, 4); p += 4;
+	l = ((long int) final[ 3]<<16) | ((long int) final[ 9]<<8) | final[15];
+	_crypt_to64(p, l, 4); p += 4;
+	l = ((long int) final[ 4]<<16) | ((long int) final[10]<<8) | final[ 5];
+#else
 	l = (final[ 0]<<16) | (final[ 6]<<8) | final[12];
 	_crypt_to64(p, l, 4); p += 4;
 	l = (final[ 1]<<16) | (final[ 7]<<8) | final[13];
@@ -142,6 +153,7 @@ crypt_md5_r(const char *pw, const char *salt, struct crypt_data *data)
 	l = (final[ 3]<<16) | (final[ 9]<<8) | final[15];
 	_crypt_to64(p, l, 4); p += 4;
 	l = (final[ 4]<<16) | (final[10]<<8) | final[ 5];
+#endif
 	_crypt_to64(p, l, 4); p += 4;
 	l = final[11];
 	_crypt_to64(p, l, 2); p += 2;
-- 
1.9.3




More information about the devel mailing list