diff options
Diffstat (limited to 'kerberosIV/krb/get_krbrlm.c')
-rw-r--r-- | kerberosIV/krb/get_krbrlm.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/kerberosIV/krb/get_krbrlm.c b/kerberosIV/krb/get_krbrlm.c index d771fa878eb..11de4231b19 100644 --- a/kerberosIV/krb/get_krbrlm.c +++ b/kerberosIV/krb/get_krbrlm.c @@ -1,3 +1,4 @@ +/* $OpenBSD: get_krbrlm.c,v 1.9 1997/12/09 07:57:17 art Exp $ */ /* $KTH: get_krbrlm.c,v 1.16 1997/05/02 01:26:22 assar Exp $ */ /* @@ -50,7 +51,8 @@ krb_get_lrealm_f(char *r, int n, const char *fname) char *p = buf + strspn(buf, " \t"); p[strcspn(p, " \t\r\n")] = 0; p[REALM_SZ - 1] = 0; - strcpy(r, p); + strncpy(r, p, REALM_SZ); + r[REALM_SZ-1] = '\0'; if (*p != '#') ret = KSUCCESS; } @@ -71,7 +73,7 @@ krb_get_lrealm(char *r, int n) return(KFAILURE); /* Temporary restriction */ /* First try user specified file */ - if (dir != 0) { + if (dir != 0 && getuid() != geteuid()) { char fname[MAXPATHLEN]; if(k_concat(fname, sizeof(fname), dir, "/krb.conf", NULL) == 0) if (krb_get_lrealm_f(r, n, fname) == KSUCCESS) @@ -92,7 +94,8 @@ krb_get_lrealm(char *r, int n) k_gethostname(hostname, sizeof(hostname)); t = krb_realmofhost(hostname); if (t) { - strcpy (r, t); + strncpy (r, t, REALM_SZ); + r[REALM_SZ-1] = '\0'; return KSUCCESS; } t = strchr(hostname, '.'); @@ -114,7 +117,9 @@ char * krb_get_default_realm(void) { static char local_realm[REALM_SZ]; /* local kerberos realm */ - if (krb_get_lrealm(local_realm, 1) != KSUCCESS) - strcpy(local_realm, "NO.DEFAULT.REALM"); + if (krb_get_lrealm(local_realm, 1) != KSUCCESS){ + strncpy(local_realm, "NO.DEFAULT.REALM", REALM_SZ); + local_realm[REALM_SZ-1] = '\0'; + } return local_realm; } |