summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernd Schmidt <bernds_cb1@t-online.de>2008-06-10 11:38:53 +0000
committerBernd Schmidt <bernds_cb1@t-online.de>2008-06-10 11:38:53 +0000
commita7afdf1cacc93d2239977dbadd7a16e3653e3a33 (patch)
treea8755e3e6afb96035fc70d639d91e20726042eb5
parent212bd82fe640619297cb51bd2bb109aa7b500ee1 (diff)
Revert revison 19346, except parts needed by later patches (r19347 also added
__uc_malloc calls in getnetent.c, so we must retain the include and libc_hidden_proto).
-rw-r--r--libc/inet/getnetent.c25
-rw-r--r--libcrypt/md5.c23
2 files changed, 14 insertions, 34 deletions
diff --git a/libc/inet/getnetent.c b/libc/inet/getnetent.c
index d9122f4e2..6224243d1 100644
--- a/libc/inet/getnetent.c
+++ b/libc/inet/getnetent.c
@@ -36,9 +36,14 @@ libc_hidden_proto(__uc_malloc)
#include <bits/uClibc_mutex.h>
__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
-static const char NETDB[] = _PATH_NETWORKS;
+
+#define MAXALIASES 35
+static const char NETDB[] = _PATH_NETWORKS;
static FILE *netf = NULL;
+static char *line = NULL;
+static struct netent net;
+static char *net_aliases[MAXALIASES];
smallint _net_stayopen attribute_hidden;
@@ -82,22 +87,6 @@ static char * any(register char *cp, char *match)
return ((char *)0);
}
-#define MAXALIASES 35
-static struct {
- char *line;
- struct netent net;
- char *net_aliases[MAXALIASES];
-} *sp;
-#define line (sp->line)
-#define net (sp->net)
-#define net_aliases (sp->net_aliases)
-#define INIT_SP() { \
- if (!sp) { \
- sp = __uc_malloc(sizeof(*sp)); \
- line = NULL; \
- } \
-}
-
libc_hidden_proto(getnetent)
struct netent *getnetent(void)
{
@@ -105,8 +94,6 @@ struct netent *getnetent(void)
register char *cp, **q;
struct netent *rv = NULL;
- INIT_SP();
-
__UCLIBC_MUTEX_LOCK(mylock);
if (netf == NULL && (netf = fopen(NETDB, "r" )) == NULL) {
goto DONE;
diff --git a/libcrypt/md5.c b/libcrypt/md5.c
index 5580d21ff..6706f9279 100644
--- a/libcrypt/md5.c
+++ b/libcrypt/md5.c
@@ -76,7 +76,6 @@
#include <sys/types.h>
#include <string.h>
#include <unistd.h>
-#include <malloc.h>
#include <stdio.h>
#include <crypt.h>
#include <sys/cdefs.h>
@@ -96,10 +95,7 @@ static void __md5_Final (unsigned char [16], struct MD5Context *);
static void __md5_Transform __P((u_int32_t [4], const unsigned char [64]));
-#define MD5_MAGIC_STR "$1$"
-#define MD5_MAGIC_LEN (sizeof(MD5_MAGIC_STR) - 1)
-static const unsigned char __md5__magic[] = MD5_MAGIC_STR;
- /* This string is magic for this algorithm. Having
+static const unsigned char __md5__magic[] = "$1$"; /* This string is magic for this algorithm. Having
it this way, we can get better later on */
static const unsigned char __md5_itoa64[] = /* 0 ... 63 => ascii - 64 */
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
@@ -534,24 +530,21 @@ static void __md5_to64( char *s, unsigned long v, int n)
char *__md5_crypt(const unsigned char *pw, const unsigned char *salt)
{
/* Static stuff */
- static char *passwd;
+ static const unsigned char *sp, *ep;
+ static char passwd[120], *p;
- const unsigned char *sp, *ep;
- char *p;
unsigned char final[17]; /* final[16] exists only to aid in looping */
- int sl,pl,i,pw_len;
+ int sl,pl,i,__md5__magic_len,pw_len;
struct MD5Context ctx,ctx1;
unsigned long l;
- if (!passwd)
- passwd = __uc_malloc(120);
-
/* Refine the Salt first */
sp = salt;
/* If it starts with the magic string, then skip that */
- if(!strncmp(sp,__md5__magic,MD5_MAGIC_LEN))
- sp += MD5_MAGIC_LEN;
+ __md5__magic_len = strlen(__md5__magic);
+ if(!strncmp(sp,__md5__magic,__md5__magic_len))
+ sp += __md5__magic_len;
/* It stops at the first '$', max 8 chars */
for(ep=sp;*ep && *ep != '$' && ep < (sp+8);ep++)
@@ -567,7 +560,7 @@ char *__md5_crypt(const unsigned char *pw, const unsigned char *salt)
__md5_Update(&ctx,pw,pw_len);
/* Then our magic string */
- __md5_Update(&ctx,__md5__magic,MD5_MAGIC_LEN);
+ __md5_Update(&ctx,__md5__magic,__md5__magic_len);
/* Then the raw salt */
__md5_Update(&ctx,sp,sl);