From owner-freebsd-bugs@FreeBSD.ORG Mon Jan 28 07:30:01 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0370A16A41A for ; Mon, 28 Jan 2008 07:30:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id D6E2313C455 for ; Mon, 28 Jan 2008 07:30:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m0S7U0GS092357 for ; Mon, 28 Jan 2008 07:30:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m0S7U00x092356; Mon, 28 Jan 2008 07:30:00 GMT (envelope-from gnats) Resent-Date: Mon, 28 Jan 2008 07:30:00 GMT Resent-Message-Id: <200801280730.m0S7U00x092356@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Takumi Nakamura Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5D65916A41B for ; Mon, 28 Jan 2008 07:21:53 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 4D4B013C4E8 for ; Mon, 28 Jan 2008 07:21:53 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m0S7K98j030592 for ; Mon, 28 Jan 2008 07:20:09 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.2/8.14.1/Submit) id m0S7K9d2030591; Mon, 28 Jan 2008 07:20:09 GMT (envelope-from nobody) Message-Id: <200801280720.m0S7K9d2030591@www.freebsd.org> Date: Mon, 28 Jan 2008 07:20:09 GMT From: Takumi Nakamura To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/120075: Incompatible EOS of key in crypt(3) X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jan 2008 07:30:01 -0000 >Number: 120075 >Category: misc >Synopsis: Incompatible EOS of key in crypt(3) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Jan 28 07:30:00 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Takumi Nakamura >Release: FreeBSD 6.2-RELEASE-p9 >Organization: >Environment: FreeBSD ***** 6.2-RELEASE-p9 FreeBSD 6.2-RELEASE-p9 #4: Mon Dec 3 15:31:44 JST 2007 *****:/usr/obj/usr/src/sys/GENERIC i386 >Description: In, crypt_des(key,salt) 0x80(not \0) in key is treated as end of string. I expect the result below differs; crypt("\x8B\xAE\xAE\xE4\x9a\x9F\x80\x82", "..") and crypt("\x8B\xAE\xAE\xE4\x9a\x9F", "..") It is imcompatibility among other OSes, GNU/Linux(glibc), NetBSD, Darwin, &c. There is no way for kludge to keep compatibility on FreeBSD. >How-To-Repeat: /* FreeBSD 6.2-RELEASE-p9 crypt( 8B AE AE E4 9A 9F 80 82 )=..cSVY0lhu7BA crypt( 8B AE AE E4 9A 9F 80 00 )=..cSVY0lhu7BA crypt( 8B AE AE E4 9A 9F 00 82 )=..cSVY0lhu7BA crypt( 8B AE AE E4 9A 9F 00 80 )=..cSVY0lhu7BA GNU/Linux glibc x86 crypt( 8B AE AE E4 9A 9F 80 82 )=..riUAaAAAAAA crypt( 8B AE AE E4 9A 9F 80 00 )=..cSVY0lhu7BA crypt( 8B AE AE E4 9A 9F 00 82 )=..cSVY0lhu7BA crypt( 8B AE AE E4 9A 9F 00 80 )=..cSVY0lhu7BA Cygwin crypt( 8B AE AE E4 9A 9F 80 82 )=..riUAaAAAAAA crypt( 8B AE AE E4 9A 9F 80 00 )=..cSVY0lhu7BA crypt( 8B AE AE E4 9A 9F 00 82 )=..cSVY0lhu7BA crypt( 8B AE AE E4 9A 9F 00 80 )=..cSVY0lhu7BA Darwin 8.11.0 (MacOSX PPC) crypt( 8B AE AE E4 9A 9F 80 82 )=..riUAaAAAAAA crypt( 8B AE AE E4 9A 9F 80 00 )=..cSVY0lhu7BA crypt( 8B AE AE E4 9A 9F 00 82 )=..cSVY0lhu7BA crypt( 8B AE AE E4 9A 9F 00 80 )=..cSVY0lhu7BA */ #include #include static void report(char const *key) { int i; printf("crypt("); for (i = 0; i < 8; i++) printf(" %02X", key[i] & 0xFF); printf(" )=%s\n", crypt(key, "..")); } int main() { report("\x8B\xAE\xAE\xE4\x9a\x9F\x80\x82"); /* Incompatible */ report("\x8B\xAE\xAE\xE4\x9a\x9F\x80\x00"); report("\x8B\xAE\xAE\xE4\x9a\x9F\x00\x82"); report("\x8B\xAE\xAE\xE4\x9a\x9F\x00\x80"); return 0; } >Fix: quoted from crypt_des(), /src/secure/lib/libcrypt/crypt-des.c /* * Copy the key, shifting each character up by one bit * and padding with zeros. */ q = (u_char *)keybuf; while (q - (u_char *)keybuf - 8) { *q++ = *key << 1; if (*(q - 1)) key++; } for example with minimal modification; q = (u_char *)keybuf; while (q - (u_char *)keybuf - 8) { *q++ = *key << 1; if (*key) key++; } (I guess it will be also bad code because it is not aliasing-safe) Or, refer the specific limitation of EOS in the manpage. (I don't hope) >Release-Note: >Audit-Trail: >Unformatted: