extern char *pw_encrypt(const char *clear, const char *salt) { static char cipher[128]; char *cp; #ifdef CONFIG_FEATURE_SHA1_PASSWORDS if (strncmp(salt, "$2$", 3) == 0) { return sha1_crypt(clear); } #endif cp = (char *) crypt(clear, salt); /* if crypt (a nonstandard crypt) returns a string too large, truncate it so we don't overrun buffers and hope there is enough security in what's left */ safe_strncpy(cipher, cp, sizeof(cipher)); return cipher; }
extern char *pw_encrypt(const char *clear, const char *salt) { static char cipher[128]; char *cp; #if defined(IFX_SMALL_FOOTPRINT) && defined(IFX_DLOAD_LIBCRYPT) char *(*crypt_ptr)(char *,char *) = NULL; void *dlHandle = NULL; char *error = NULL; #endif #ifdef CONFIG_FEATURE_SHA1_PASSWORDS if (strncmp(salt, "$2$", 3) == 0) { return sha1_crypt(clear); } #endif #if defined(IFX_SMALL_FOOTPRINT) && defined(IFX_DLOAD_LIBCRYPT) dlHandle = dlopen(LIBCRYPT,RTLD_LAZY); if(dlHandle) { crypt_ptr = dlsym(dlHandle,"crypt"); if((error = dlerror()) != NULL) { bb_error_msg_and_die ( "could not find function crypt in libcrypt. Error : %s",error); } cp = (char *)(*crypt_ptr)(clear, salt); dlclose(dlHandle); } else { bb_error_msg_and_die ( "could not open library %s",LIBCRYPT); } #else cp = (char *) crypt(clear, salt); #endif /* if crypt (a nonstandard crypt) returns a string too large, truncate it so we don't overrun buffers and hope there is enough security in what's left */ safe_strncpy(cipher, cp, sizeof(cipher)); return cipher; }