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

Joel Sherrill joel.sherrill at oarcorp.com
Thu Mar 26 00:41:18 UTC 2015



On March 24, 2015 8:37:57 AM CDT, Daniel Gutson <daniel.gutson at tallertechnologies.com> wrote:
>In order to avoid code duplication and ease future bugfixing, I suggest
>to have a conditional casting and leave the core code alone, something
>like
>
>#ifdef __rtems__
>#define cast(x) ((unsigned long int)x)
>#else
>#define cast(x) (x)
>#endif
>
>...cast(final[ 0] << 16)...
>
>#undef cast

Good suggestion. The big concern is really just making sure changes made to the imported code is clear. I suppose this does it as well. 


>El 23/03/2015 11:52, "Joel Sherrill" <joel.sherrill at oarcorp.com>
>escribió:
>
>---
> 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
>
>_______________________________________________
>devel mailing list
>devel at rtems.org
>http://lists.rtems.org/mailman/listinfo/devel

--joel


More information about the devel mailing list