aklog: strlen(NULL) doesn't work

strlen(filepath) when !filepath isnt going to work very well. i believe
this to be the intent of the author of the original patch.

Reviewed-on: http://gerrit.openafs.org/5328
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
(cherry picked from commit c3e82ee98bf66058636f11d7a98d3bebe3bac955)

Change-Id: I89911d2da314059db633c00c69c9c9ec2050bb86
Reviewed-on: http://gerrit.openafs.org/6311
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: Derrick Brashear <shadow@dementix.org>
This commit is contained in:
Derrick Brashear 2011-09-02 13:35:24 -04:00
parent 05f3dcdbbf
commit 44597ff4ce

View File

@ -1520,19 +1520,15 @@ main(int argc, char *argv[])
#if defined(KRB5_PROG_ETYPE_NOSUPP) && !(defined(HAVE_KRB5_ENCTYPE_ENABLE) || defined(HAVE_KRB5_ALLOW_WEAK_CRYPTO))
{
char *filepath = NULL, *newpath = NULL;
filepath = getenv("KRB5_CONFIG");
if (!filepath) {
int slen;
#ifndef AFS_DARWIN_ENV
slen = strlen(filepath)+strlen(":/etc/krb5.conf")+1;
newpath = malloc(slen);
snprintf(newpath, slen, "%s:/etc/krb5.conf", filepath);
char *defaultpath = "/etc/krb5.conf";
#else
slen = strlen("~/Library/Preferences/edu.mit.Kerberos:/Library/Preferences/edu.mit.Kerberos:")+strlen(AFSDIR_CLIENT_ETC_DIRPATH)+strlen("/krb5-weak.conf")+1;
newpath = malloc(slen);
snprintf(newpath, slen, "~/Library/Preferences/edu.mit.Kerberos:/Library/Preferences/edu.mit.Kerberos:%s/krb5-weak.conf", AFSDIR_CLIENT_ETC_DIRPATH);
char *defaultpath = "~/Library/Preferences/edu.mit.Kerberos:/Library/Preferences/edu.mit.Kerberos";
#endif
}
filepath = getenv("KRB5_CONFIG");
afs_asprintf(&newpath, "%s:%s/krb5-weak.conf",
filepath ? filepath : defaultpath,
AFSDIR_CLIENT_ETC_DIRPATH);
setenv("KRB5_CONFIG", newpath, 1);
#endif
krb5_init_context(&context);