From b02e2db0712f943ad794d98a6e9c01378860960a Mon Sep 17 00:00:00 2001 From: David Sommerseth Date: Fri, 31 Dec 2010 18:05:03 +0100 Subject: Make use of more cross-platform friendly libc functions The initial implementation of the SHA512 hashing functions was tightly connected to glibc. This patch changes those few functions which is glibc to more portable functions. Signed-off-by: David Sommerseth --- common/passwd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/common/passwd.c b/common/passwd.c index 4408e02..217fa0c 100644 --- a/common/passwd.c +++ b/common/passwd.c @@ -327,7 +327,8 @@ inline char *sha512_crypt_r(const char *key, const char *salt, size_t maxrounds_ /* Create byte sequence P. */ cp = p_bytes = alloca (key_len); for (cnt = key_len; cnt >= 64; cnt -= 64) { - cp = mempcpy (cp, temp_result, 64); + cp = memcpy (cp, temp_result, 64); + cp += 64; } memcpy (cp, temp_result, cnt); @@ -345,7 +346,8 @@ inline char *sha512_crypt_r(const char *key, const char *salt, size_t maxrounds_ /* Create byte sequence S. */ cp = s_bytes = alloca (salt_len); for (cnt = salt_len; cnt >= 64; cnt -= 64) { - cp = mempcpy (cp, temp_result, 64); + cp = memcpy (cp, temp_result, 64); + cp += 64; } memcpy (cp, temp_result, cnt); @@ -386,7 +388,7 @@ inline char *sha512_crypt_r(const char *key, const char *salt, size_t maxrounds_ /* Now we can construct the result string. It consists of three parts. */ - cp = __stpncpy (buffer, salt, MIN ((size_t) MAX (0, buflen), salt_len)); + cp = stpncpy (buffer, salt, MIN ((size_t) MAX (0, buflen), salt_len)); buflen -= MIN ((size_t) MAX (0, buflen), salt_len); b64_from_24bit (alt_result[0], alt_result[21], alt_result[42], 4); -- cgit