From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 5 15:39:57 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9503DE52; Thu, 5 Jun 2014 15:39:57 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 810D42B4B; Thu, 5 Jun 2014 15:39:57 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s55Fdvkl029284; Thu, 5 Jun 2014 15:39:57 GMT (envelope-from ume@svn.freebsd.org) Received: (from ume@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s55FdvmU029282; Thu, 5 Jun 2014 15:39:57 GMT (envelope-from ume@svn.freebsd.org) Message-Id: <201406051539.s55FdvmU029282@svn.freebsd.org> From: Hajimu UMEMOTO Date: Thu, 5 Jun 2014 15:39:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r267116 - stable/9/lib/libcrypt X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Jun 2014 15:39:57 -0000 Author: ume Date: Thu Jun 5 15:39:57 2014 New Revision: 267116 URL: http://svnweb.freebsd.org/changeset/base/267116 Log: MFH r266813: Don't break the legacy applications which set just 2 bytes to salt. Approved by: re (gjb) Modified: stable/9/lib/libcrypt/crypt.c Directory Properties: stable/9/lib/libcrypt/ (props changed) Modified: stable/9/lib/libcrypt/crypt.c ============================================================================== --- stable/9/lib/libcrypt/crypt.c Thu Jun 5 15:39:54 2014 (r267115) +++ stable/9/lib/libcrypt/crypt.c Thu Jun 5 15:39:57 2014 (r267116) @@ -104,12 +104,16 @@ char * crypt(const char *passwd, const char *salt) { const struct crypt_format *cf; +#ifdef HAS_DES + int len; +#endif for (cf = crypt_formats; cf->name != NULL; ++cf) if (cf->magic != NULL && strstr(salt, cf->magic) == salt) return (cf->func(passwd, salt)); #ifdef HAS_DES - if (strlen(salt) == 13 && strspn(salt, DES_SALT_ALPHABET) == 13) + len = strlen(salt); + if ((len == 13 || len == 2) && strspn(salt, DES_SALT_ALPHABET) == len) return (crypt_des(passwd, salt)); #endif return (crypt_format->func(passwd, salt));