From 4d04026180a6e20b3c8d68ceecb1255d51c22e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Thu, 10 May 2007 21:57:58 +0000 Subject: [PATCH] There is a diffrence between the no password string and the empty string, in the empty string the UTF16 NUL terminator is included into the string. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20661 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/hcrypto/pkcs12.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/hcrypto/pkcs12.c b/lib/hcrypto/pkcs12.c index 6b2af8033..c8a2f5a16 100644 --- a/lib/hcrypto/pkcs12.c +++ b/lib/hcrypto/pkcs12.c @@ -77,7 +77,12 @@ PKCS12_key_gen(const void *key, size_t keylen, I[i] = ((unsigned char*)salt)[i % saltlen]; size_I += vlen; } - if (key && keylen > 0) { + /* + * There is a diffrence between the no password string and the + * empty string, in the empty string the UTF16 NUL terminator is + * included into the string. + */ + if (key && keylen >= 0) { for (i = 0; i < vlen / 2; i++) { I[(i * 2) + size_I] = 0; I[(i * 2) + size_I + 1] = ((unsigned char*)key)[i % (keylen + 1)];