X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=libbb%2Fpw_encrypt.c;h=f6085f3d2c541fedab12a8890828381e7845ec40;hb=079f8afa0a16112cbaf7012c82b38b7358b82141;hp=0e4eb9f8a8635a6207ff7cb635e8e522ad57d6a8;hpb=27f64e1f4eb4354844f6553e37501deffde8373e;p=oweals%2Fbusybox.git diff --git a/libbb/pw_encrypt.c b/libbb/pw_encrypt.c index 0e4eb9f8a..f6085f3d2 100644 --- a/libbb/pw_encrypt.c +++ b/libbb/pw_encrypt.c @@ -2,35 +2,21 @@ /* * Utility routine. * - * Copyright (C) 1999-2002 by Erik Andersen - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Copyright (C) 1999-2004 by Erik Andersen * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ +#include "libbb.h" #include #include -#include "libbb.h" - -extern char *pw_encrypt(const char *clear, const char *salt) +char *pw_encrypt(const char *clear, const char *salt) { static char cipher[128]; char *cp; -#ifdef CONFIG_FEATURE_SHA1_PASSWORDS +#if 0 /* was CONFIG_FEATURE_SHA1_PASSWORDS, but there is no such thing??? */ if (strncmp(salt, "$2$", 3) == 0) { return sha1_crypt(clear); } @@ -39,10 +25,6 @@ extern char *pw_encrypt(const char *clear, const char *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 */ - if (strlen(cp) > sizeof(cipher)-1) { - cp[sizeof(cipher)-1] = 0; - } - strcpy(cipher, cp); + safe_strncpy(cipher, cp, sizeof(cipher)); return cipher; } -