krb5 commit [krb5-1.11]: Check for asprintf failure in kdb5_util create
Tom Yu
tlyu at mit.edu
Fri Feb 6 17:27:00 EST 2015
https://github.com/krb5/krb5/commit/337a1f7b013fe18332614a539af3872d1ce89295
commit 337a1f7b013fe18332614a539af3872d1ce89295
Author: Tomas Kuthan <tkuthan at gmail.com>
Date: Thu Apr 10 15:16:06 2014 +0200
Check for asprintf failure in kdb5_util create
In add_admin_princ, remove build_name_with_realm and call asprintf
directly instead. Check for asprintf failure to avoid passing an
undefined pointer to krb5_parse_name.
[ghudson at mit.edu: rewrite commit message]
(cherry picked from commit f5645d30cf83398640c386a612eb6f07c543286f)
ticket: 8097 (new)
version_fixed: 1.11.6
status: resolved
src/kadmin/dbutil/kadm5_create.c | 30 ++++--------------------------
1 files changed, 4 insertions(+), 26 deletions(-)
diff --git a/src/kadmin/dbutil/kadm5_create.c b/src/kadmin/dbutil/kadm5_create.c
index 567f5f5..4abad5b 100644
--- a/src/kadmin/dbutil/kadm5_create.c
+++ b/src/kadmin/dbutil/kadm5_create.c
@@ -126,31 +126,6 @@ int kadm5_create_magic_princs(kadm5_config_params *params,
}
/*
- * Function: build_name_with_realm
- *
- * Purpose: concatenate a name and a realm to form a krb5 name
- *
- * Arguments:
- *
- * name (input) the name
- * realm (input) the realm
- *
- * Returns:
- *
- * pointer to name at realm, in allocated memory, or NULL if it
- * cannot be allocated
- *
- * Requires: both strings are null-terminated
- */
-static char *build_name_with_realm(char *name, char *realm)
-{
- char *n;
-
- asprintf(&n, "%s@%s", name, realm);
- return n;
-}
-
-/*
* Function: add_admin_princs
*
* Purpose: create admin principals
@@ -284,7 +259,10 @@ int add_admin_princ(void *handle, krb5_context context,
memset(&ent, 0, sizeof(ent));
- fullname = build_name_with_realm(name, realm);
+ if (asprintf(&fullname, "%s@%s", name, realm) < 0) {
+ com_err(progname, ENOMEM, _("while appending realm to principal"));
+ return ERR;
+ }
ret = krb5_parse_name(context, fullname, &ent.principal);
if (ret) {
com_err(progname, ret, _("while parsing admin principal name"));
More information about the cvs-krb5
mailing list