From 77df9e16742508c9f0c2ad08a6f70faa07dd22ce Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Fri, 6 Jun 2003 14:44:33 +0000 Subject: * g_cnffile.c (krb__get_srvtabname): Make retname be a static array rather than a static pointer, to avoid callers' possible retention of free()d pointers. Yes, this may cause difficulty with making this function thread-safe. ticket: 1563 target_version: 1.3 version_fixed: 1.3 tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@15589 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb4/ChangeLog | 7 +++++++ src/lib/krb4/g_cnffile.c | 12 +++++------- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/lib/krb4/ChangeLog b/src/lib/krb4/ChangeLog index 2e6e0141c7..d779412b57 100644 --- a/src/lib/krb4/ChangeLog +++ b/src/lib/krb4/ChangeLog @@ -1,3 +1,10 @@ +2003-06-06 Tom Yu + + * g_cnffile.c (krb__get_srvtabname): Make retname be a static + array rather than a static pointer, to avoid callers' possible + retention of free()d pointers. Yes, this may cause difficulty + with making this function thread-safe. + 2003-06-04 Tom Yu * password_to_key.c (mit_passwd_to_key, afs_passwd_to_key): Delete diff --git a/src/lib/krb4/g_cnffile.c b/src/lib/krb4/g_cnffile.c index 8d61f50565..dd5ed5c60d 100644 --- a/src/lib/krb4/g_cnffile.c +++ b/src/lib/krb4/g_cnffile.c @@ -56,7 +56,7 @@ krb__get_srvtabname(default_srvtabname) const char* names[3]; char **full_name = 0, **cpp; krb5_error_code retval; - static char *retname; + static char retname[MAXPATHLEN]; if (!krb5__krb4_context) krb5_init_context(&krb5__krb4_context); @@ -67,18 +67,16 @@ krb__get_srvtabname(default_srvtabname) retval = profile_get_values(krb5__krb4_context->profile, names, &full_name); if (retval == 0 && full_name && full_name[0]) { - if (retname != NULL) - free(retname); - retname = strdup(full_name[0]); + retname[0] = '\0'; + strncat(retname, full_name[0], sizeof(retname)); for (cpp = full_name; *cpp; cpp++) krb5_xfree(*cpp); krb5_xfree(full_name); return retname; } } - if (retname != NULL) - free(retname); - retname = strdup(default_srvtabname); + retname[0] = '\0'; + strncat(retname, default_srvtabname, sizeof(retname)); return retname; } -- cgit