Browse Source

fix by Bernhard Fischer to move local prototypes to a header to keep things sane

Mike Frysinger 17 years ago
parent
commit
8d9ff89b64
4 changed files with 29 additions and 20 deletions
  1. 4 6
      libcrypt/crypt.c
  2. 2 3
      libcrypt/des.c
  3. 20 0
      libcrypt/libcrypt.h
  4. 3 11
      libcrypt/md5.c

+ 4 - 6
libcrypt/crypt.c

@@ -8,16 +8,14 @@
 #define __FORCE_GLIBC
 #include <crypt.h>
 #include <unistd.h>
+#include "libcrypt.h"
 
-extern char * __md5_crypt( const char *pw, const char *salt) attribute_hidden;
-extern char * __des_crypt( const char *pw, const char *salt) attribute_hidden;
-
-char * crypt(const char *key, const char *salt)
+char *crypt(const char *key, const char *salt)
 {
 	/* First, check if we are supposed to be using the MD5 replacement
 	 * instead of DES...  */
 	if (salt[0]=='$' && salt[1]=='1' && salt[2]=='$')
-		return __md5_crypt(key, salt);
+		return __md5_crypt((unsigned char*)key, (unsigned char*)salt);
 	else
-		return __des_crypt(key, salt);
+		return __des_crypt((unsigned char*)key, (unsigned char*)salt);
 }

+ 2 - 3
libcrypt/des.c

@@ -64,6 +64,7 @@
 #include <pwd.h>
 #include <string.h>
 #include <crypt.h>
+#include "libcrypt.h"
 
 /* Re-entrantify me -- all this junk needs to be in 
  * struct crypt_data to make this really reentrant... */
@@ -638,9 +639,7 @@ encrypt(char *block, int flag)
 			block[(i << 5) | j] = (io[i] & bits32[j]) ? 1 : 0;
 }
 
-char *__des_crypt(const char *key, const char *setting) attribute_hidden;
-char *
-__des_crypt(const char *key, const char *setting)
+char *__des_crypt(const unsigned char *key, const unsigned char *setting)
 {
 	u_int32_t	count, salt, l, r0, r1, keybuf[2];
 	u_char		*p, *q;

+ 20 - 0
libcrypt/libcrypt.h

@@ -0,0 +1,20 @@
+/* prototypes for internal crypt functions
+ *
+ * Copyright (C) 2000-2006 by Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#ifndef __LIBCRYPT_H__
+#define __LIBCRYPT_H__
+
+extern char *__md5_crypt(const unsigned char *pw, const unsigned char *salt) attribute_hidden;
+extern char *__des_crypt(const unsigned char *pw, const unsigned char *salt) attribute_hidden;
+
+/* shut up gcc-4.x signed warnings */
+#define strcpy(dst,src) strcpy((char*)dst,(char*)src)
+#define strlen(s) strlen((char*)s)
+#define strncat(dst,src,n) strncat((char*)dst,(char*)src,n)
+#define strncmp(s1,s2,n) strncmp((char*)s1,(char*)s2,n)
+
+#endif

+ 3 - 11
libcrypt/md5.c

@@ -79,7 +79,8 @@
 #include <stdio.h>
 #include <crypt.h>
 #include <sys/cdefs.h>
-	
+#include "libcrypt.h"
+
 /* MD5 context. */
 struct MD5Context {
   u_int32_t state[4];	/* state (ABCD) */
@@ -100,14 +101,6 @@ static const unsigned char __md5_itoa64[] =		/* 0 ... 63 => ascii - 64 */
 	"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
 
 
-/* shut up gcc-4.x signed warnings */
-#define strcpy(dst,src) strcpy((char*)dst,(char*)src)
-#define strlen(s) strlen((char*)s)
-#define strncat(dst,src,n) strncat((char*)dst,(char*)src,n)
-#define strncmp(s1,s2,n) strncmp((char*)s1,(char*)s2,n)
-
-
-
 #ifdef i386
 #define __md5_Encode memcpy
 #define __md5_Decode memcpy
@@ -538,8 +531,7 @@ static void __md5_to64( char *s, unsigned long v, int n)
  * Use MD5 for what it is best at...
  */
 
-char * __md5_crypt( const unsigned char *pw, const unsigned char *salt) attribute_hidden;
-char * __md5_crypt( const unsigned char *pw, const unsigned char *salt)
+char *__md5_crypt(const unsigned char *pw, const unsigned char *salt)
 {
 	/* Static stuff */
 	static const unsigned char *sp, *ep;