[PATCH] use 36 byte buffer in md5 instead of 120, shrink code
peter.kjellerstedt at axis.com
Fri Jun 13 17:30:11 UTC 2008
> -----Original Message-----
> From: uclibc-bounces at uclibc.org [mailto:uclibc-bounces at uclibc.org] On
> Behalf Of Denys Vlasenko
> Sent: den 13 juni 2008 17:46
> To: uclibc at uclibc.org
> Subject: Re: [PATCH] use 36 byte buffer in md5 instead of 120, shrink
> On Friday 13 June 2008 17:45, Denys Vlasenko wrote:
> > md5 crypt stores result in the form $1$xxx$yyyyyyyyy<NUL>
> > where xxx is salt (up to 8 chars) and yyy is hash
> > (22 chars). Using 120 bytes buffer for it is excessive.
> > The patch also replaces e.g. strcat(passwd,"$")
> > which writes $ between xxx and yyyy above with one-byte store,
> > which is shorter.
> > __md5_to64 is made to return advanced pointer, eliminating
> > the need to do it at call sites.
> > Size:
> > text data bss dec hex filename
> > - 1905 0 120 2025 7e9 libcrypt/md5.o
> > + 1879 0 36 1915 77b libcrypt/md5.o
> > Run tested:
> > TEST_EXEC crypt/ crypt
> > TEST_DIFF crypt/ crypt.out crypt.out.good
> > TEST_EXEC crypt/ md5c-test
> > TEST_EXEC crypt/ crypt_glibc
> > TEST_DIFF crypt/ crypt_glibc.out crypt.out.good
> > TEST_EXEC crypt/ md5c-test_glibc
> > Please review.
> Now even with patch actually attached.
You changed the type of the second argument to __md5_to64() from
unsigned long to unsigned, but in __md5_crypt() you are still
passing it l (stupid variable name) which is unsigned long.
More information about the uClibc