From: Theodore Tso Date: Thu, 21 Feb 1991 11:42:50 +0000 (+0000) Subject: Changes to conform with API modifications (to krb5_get_default_realm) X-Git-Tag: krb5-1.0-alpha4~221 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=608b216a05c7fd202c9480dc1cde2672b8c9df2c;p=krb5.git Changes to conform with API modifications (to krb5_get_default_realm) git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1751 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/os/an_to_ln.c b/src/lib/krb5/os/an_to_ln.c index 7e33a0365..02e6bab4f 100644 --- a/src/lib/krb5/os/an_to_ln.c +++ b/src/lib/krb5/os/an_to_ln.c @@ -119,15 +119,13 @@ char *lname; } realm_length = krb5_princ_realm(aname)->length; - if (!(def_realm = malloc(realm_length + 1))) - return ENOMEM; - if (retval = krb5_get_default_realm(realm_length+1,def_realm)) { - free(def_realm); - return KRB5_LNAME_NOTRANS; + if (retval = krb5_get_default_realm(&def_realm)) { + return(retval); } - if (strncmp(def_realm, krb5_princ_realm(aname)->data, realm_length)) { + if ((realm_length != strlen(def_realm)) || + (memcmp(def_realm, krb5_princ_realm(aname)->data, realm_legth))) { free(def_realm); return KRB5_LNAME_NOTRANS; } diff --git a/src/lib/krb5/os/def_realm.c b/src/lib/krb5/os/def_realm.c index 516b90697..093730937 100644 --- a/src/lib/krb5/os/def_realm.c +++ b/src/lib/krb5/os/def_realm.c @@ -22,14 +22,11 @@ static char rcsid_def_realm_c[] = #include /* - Retrieves the default realm to be used if no user-specified realm is - available. [e.g. to interpret a user-typed principal name with the - realm omitted for convenience] - - lnsize specifies the maximum length name that is to be filled into - lrealm. - - returns system errors, NOT_ENOUGH_SPACE + * Retrieves the default realm to be used if no user-specified realm is + * available. [e.g. to interpret a user-typed principal name with the + * realm omitted for convenience] + * + * returns system errors, NOT_ENOUGH_SPACE */ /* @@ -41,27 +38,24 @@ static char rcsid_def_realm_c[] = extern char *krb5_config_file; /* extern so can be set at load/runtime */ krb5_error_code -krb5_get_default_realm(lnsize, lrealm) -const int lnsize; -char *lrealm; +krb5_get_default_realm(lrealm) +char **lrealm; { FILE *config_file; char realmbuf[BUFSIZ]; - krb5_error_code retval; + char *cp; if (!(config_file = fopen(krb5_config_file, "r"))) /* can't open */ return KRB5_CONFIG_CANTOPEN; - if (fscanf(config_file, "%s", realmbuf) != 1) - retval = KRB5_CONFIG_BADFORMAT; - else { - strncpy(lrealm, realmbuf, lnsize); - if (lnsize < strlen(realmbuf)) - retval = KRB5_CONFIG_NOTENUFSPACE; - else - retval = 0; + if (fscanf(config_file, "%s", realmbuf) != 1) { + fclose(config_file); + return( KRB5_CONFIG_BADFORMAT); } - (void) fclose(config_file); - return retval; + fclose(config_file); + if (!(*lrealm = cp = malloc((unsigned int) strlen(realmbuf) + 1))) + return ENOMEM; + strcpy(cp, realmbuf); + return(0); } diff --git a/src/lib/krb5/os/hst_realm.c b/src/lib/krb5/os/hst_realm.c index 20a184fad..0b17b4198 100644 --- a/src/lib/krb5/os/hst_realm.c +++ b/src/lib/krb5/os/hst_realm.c @@ -105,13 +105,7 @@ char ***realmsp; if (islower(*cp)) *cp = toupper(*cp); } else { - if (!(retrealms[0] = malloc(DEF_REALMNAME_SIZE))) { - xfree(retrealms); - return ENOMEM; - } - if (retval = krb5_get_default_realm(DEF_REALMNAME_SIZE-1, - retrealms[0])) { - xfree(retrealms[0]); + if (retval = krb5_get_default_realm(&retrealms[0])) { xfree(retrealms); return retval; }