[25698] in CVS-changelog-for-Kerberos-V5
svn rev #25189: trunk/src/ lib/crypto/krb/ plugins/preauth/pkinit/
daemon@ATHENA.MIT.EDU (hartmans@mit.edu)
Sun Sep 18 20:35:01 2011
Date: Sun, 18 Sep 2011 20:34:48 -0400
From: hartmans@mit.edu
Message-Id: <201109190034.p8J0Ym76018120@drugstore.mit.edu>
To: cvs-krb5@mit.edu
Reply-To: krbdev@mit.edu
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cvs-krb5-bounces@mit.edu
http://src.mit.edu/fisheye/changelog/krb5/?cs=25189
Commit By: hartmans
Log Message:
In pkinit_crypto_openssl.c, modified pkinit_octetstring2key() to
eliminate a possible memory leak in the error path, where the
key_block->length was set to zero but the key_block->contents were
not freed. Also, changed calloc() call to a malloc() call to avoid
allocating up to 8 times as much buffer space as needed.
In keyblocks.c, modified kr5_free_keyblock_contents() to set the
key->length to zero after the key->contents have been freed.
Changed Files:
U trunk/src/lib/crypto/krb/keyblocks.c
U trunk/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c
Modified: trunk/src/lib/crypto/krb/keyblocks.c
===================================================================
--- trunk/src/lib/crypto/krb/keyblocks.c 2011-09-19 00:34:44 UTC (rev 25188)
+++ trunk/src/lib/crypto/krb/keyblocks.c 2011-09-19 00:34:48 UTC (rev 25189)
@@ -68,6 +68,7 @@
if (key && key->contents) {
zapfree(key->contents, key->length);
key->contents = NULL;
+ key->length = 0;
}
}
Modified: trunk/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c
===================================================================
--- trunk/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c 2011-09-19 00:34:44 UTC (rev 25188)
+++ trunk/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c 2011-09-19 00:34:48 UTC (rev 25189)
@@ -2143,7 +2143,7 @@
goto cleanup;
key_block->length = keylength;
- key_block->contents = calloc(keylength, sizeof(unsigned char *));
+ key_block->contents = malloc(keylength);
if (key_block->contents == NULL) {
retval = ENOMEM;
goto cleanup;
@@ -2156,9 +2156,9 @@
cleanup:
free(buf);
- if (retval && key_block->contents != NULL && key_block->length != 0) {
- memset(key_block->contents, 0, key_block->length);
- key_block->length = 0;
+ // If this is an error return, free the allocated keyblock, if any
+ if (retval) {
+ krb5_free_keyblock_contents(context, key_block);
}
return retval;
_______________________________________________
cvs-krb5 mailing list
cvs-krb5@mit.edu
https://mailman.mit.edu/mailman/listinfo/cvs-krb5