mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] crypt_blowfish: allow short salt strings
@ 2016-03-25 12:12 Timo Teräs
  2016-03-27  2:11 ` Solar Designer
  0 siblings, 1 reply; 6+ messages in thread
From: Timo Teräs @ 2016-03-25 12:12 UTC (permalink / raw)
  To: musl; +Cc: Timo Teräs

assume the remainder of the salt to be zero bits.
---
 src/crypt/crypt_blowfish.c | 2 ++
 1 file changed, 2 insertions(+)

Any comments if this makes sense?

There seems to be some test suites that even verify that short
salt strings should succeed.

See: http://bugs.alpinelinux.org/issues/5141

diff --git a/src/crypt/crypt_blowfish.c b/src/crypt/crypt_blowfish.c
index d3f7985..d1f5588 100644
--- a/src/crypt/crypt_blowfish.c
+++ b/src/crypt/crypt_blowfish.c
@@ -365,6 +365,7 @@ static const unsigned char BF_atoi64[0x60] = {
 #define BF_safe_atoi64(dst, src) \
 { \
 	tmp = (unsigned char)(src); \
+	if (tmp == 0 || tmp == '$') break; \
 	if ((unsigned int)(tmp -= 0x20) >= 0x60) return -1; \
 	tmp = BF_atoi64[tmp]; \
 	if (tmp > 63) return -1; \
@@ -624,6 +625,7 @@ static char *BF_crypt(const char *key, const char *setting,
 		return NULL;
 	}
 
+	memset(data.binary.salt, 0, sizeof data.binary.salt);
 	count = (BF_word)1 << ((setting[4] - '0') * 10 + (setting[5] - '0'));
 	if (count < min || BF_decode(data.binary.salt, &setting[7], 16)) {
 		return NULL;
-- 
2.7.4



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-03-27 15:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-25 12:12 [PATCH] crypt_blowfish: allow short salt strings Timo Teräs
2016-03-27  2:11 ` Solar Designer
2016-03-27  2:54   ` Solar Designer
2016-03-27 15:22     ` Solar Designer
2016-03-27  3:30   ` Solar Designer
2016-03-27 13:26     ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).