libcrypt/md5.c: a few statics can be auto variables; strlen("const") is silly
will.newton at gmail.com
Wed Jun 11 09:37:14 UTC 2008
On Tue, Jun 10, 2008 at 9:49 PM, Denys Vlasenko
<vda.linux at googlemail.com> wrote:
> Hi Bernd, Carmelo,
> Can you look through this patch?
> It makes sp, ep and p variables automatic.
> There is no point in having them static,
> they never use their values retained from previous call.
> These are code lines where they are assigned to:
This looks like it should be safe. Although it might be worth finding
the original author and asking why it is done this way, following the
Debian openssl incident. ;-)
> char *__md5_crypt(const unsigned char *pw, const unsigned char *salt)
> /* Refine the Salt first */
> sp = salt;
> /* It stops at the first '$', max 8 chars */
> for(ep=sp;*ep && *ep != '$' && ep < (sp+8);ep++)
> p = passwd + strlen(passwd);
> and prior to these lines, their values were never used.
> The second, much simpler change replaces
> __md5__magic_len = strlen(__md5__magic);
> and related code by compile-time constant.
Does this have any effect? I would have expected the compiler to
optimize that away.
> Effect on size:
> --- uClibc.t4/libcrypt/md5.o.disasm Tue Jun 10 22:41:17 2008
> +++ uClibc.t5/libcrypt/md5.o.disasm Tue Jun 10 22:41:17 2008
> @@ -1,5 +1,5 @@
> text data bss dec hex filename
> - 1957 0 132 2089 829 libcrypt/md5.o
> + 1905 0 120 2025 7e9 libcrypt/md5.o
> uClibc mailing list
> uClibc at uclibc.org
More information about the uClibc