From 3b47f52ce78c072c3349c3007d453b31f0e20b58 Mon Sep 17 00:00:00 2001 From: christos Date: Wed, 28 Dec 2011 03:12:38 +0000 Subject: [PATCH] clamp length to 72 (73) characters. --- lib/libcrypt/bcrypt.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/libcrypt/bcrypt.c b/lib/libcrypt/bcrypt.c index 98f3807a5518..f55fa189272e 100644 --- a/lib/libcrypt/bcrypt.c +++ b/lib/libcrypt/bcrypt.c @@ -1,4 +1,4 @@ -/* $NetBSD: bcrypt.c,v 1.14 2011/12/27 23:33:41 christos Exp $ */ +/* $NetBSD: bcrypt.c,v 1.15 2011/12/28 03:12:38 christos Exp $ */ /* $OpenBSD: bcrypt.c,v 1.16 2002/02/19 19:39:36 millert Exp $ */ /* @@ -46,7 +46,7 @@ * */ #include -__RCSID("$NetBSD: bcrypt.c,v 1.14 2011/12/27 23:33:41 christos Exp $"); +__RCSID("$NetBSD: bcrypt.c,v 1.15 2011/12/28 03:12:38 christos Exp $"); #include #include @@ -269,9 +269,11 @@ __bcrypt(key, salt) decode_base64(csalt, BCRYPT_MAXSALT, (const u_int8_t *)salt); salt_len = BCRYPT_MAXSALT; len = strlen(key); - if (len > 253) - return NULL; - key_len = (uint8_t)len + (minor >= 'a' ? 1 : 0); + if (len > 72) + key_len = 72; + else + key_len = (uint8_t)len; + key_len += minor >= 'a' ? 1 : 0; /* Setting up S-Boxes and Subkeys */ Blowfish_initstate(&state);