changeset 4152:b15a6321ae17

6475878 nss2 Memleak test suite may have exposes a mech_krb5 Memleak 6534935 Potential memory leak within libkadm5clnt.so.1 if out of memory condition occurs.
author ps57422
date Wed, 02 May 2007 06:08:06 -0700
parents ec477fe2405a
children 20265a755883
files usr/src/lib/krb5/kadm5/clnt/client_init.c usr/src/uts/common/gssapi/mechs/krb5/krb5/krb/init_ctx.c
diffstat 2 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/lib/krb5/kadm5/clnt/client_init.c	Wed May 02 03:05:01 2007 -0700
+++ b/usr/src/lib/krb5/kadm5/clnt/client_init.c	Wed May 02 06:08:06 2007 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  *
  * $Header: /cvs/krbdev/krb5/src/lib/kadm5/clnt/client_init.c,v 1.13.2.2 2000/05/09 13:17:14 raeburn Exp $
@@ -745,7 +745,10 @@
 		newsvcname = malloc(strlen(KADM5_CHANGEPW_SERVICE) +
 				    strlen(handle->params.realm) + 2);
 		if (newsvcname == NULL) {
-			return (ENOMEM);
+			ADMIN_LOGO(LOG_ERR, dgettext(TEXT_DOMAIN,
+					    "could not malloc\n"));
+			code = ENOMEM;
+			goto error;
 		}
 		sprintf(newsvcname, "%s@%s", KADM5_CHANGEPW_SERVICE,
 			handle->params.realm);
--- a/usr/src/uts/common/gssapi/mechs/krb5/krb5/krb/init_ctx.c	Wed May 02 03:05:01 2007 -0700
+++ b/usr/src/uts/common/gssapi/mechs/krb5/krb5/krb/init_ctx.c	Wed May 02 06:08:06 2007 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -408,12 +408,15 @@
 	if ((retval = krb5_set_default_tgs_ktypes(ctx, NULL)))
 		goto cleanup;
 
-	ctx->conf_tgs_ktypes = MALLOC(ctx->tgs_ktype_count * sizeof(krb5_enctype));
-	if (ctx->conf_tgs_ktypes == NULL && ctx->tgs_ktype_count != 0)
-            goto cleanup;
+	if (ctx->tgs_ktype_count != 0) {
+		ctx->conf_tgs_ktypes = MALLOC(ctx->tgs_ktype_count *
+					sizeof(krb5_enctype));
+		if (ctx->conf_tgs_ktypes == NULL)
+			goto cleanup;
 
-	(void) memcpy(ctx->conf_tgs_ktypes, ctx->tgs_ktypes,
-		sizeof(krb5_enctype) * ctx->tgs_ktype_count);
+		(void) memcpy(ctx->conf_tgs_ktypes, ctx->tgs_ktypes,
+				sizeof(krb5_enctype) * ctx->tgs_ktype_count);
+	}
 
 	ctx->conf_tgs_ktypes_count = ctx->tgs_ktype_count;