From 7ce6bdbb0af1e042b0f306dd1c1371690a9b0178 Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Mon, 15 May 2000 00:56:57 +0000 Subject: [PATCH] (krb5_524_conv_principal): comment-ize, and simplify string copying git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8230 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/krb5/principal.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/krb5/principal.c b/lib/krb5/principal.c index 47dcccc2a..5760de40c 100644 --- a/lib/krb5/principal.c +++ b/lib/krb5/principal.c @@ -821,6 +821,13 @@ name_convert(krb5_context context, const char *name, const char *realm, return -1; } +/* + * convert the v5 principal in `principal' into a v4 corresponding one + * in `name, instance, realm' + * this is limited interface since there's no length given for these + * three parameters. They have to be 40 bytes each (ANAME_SZ). + */ + krb5_error_code krb5_524_conv_principal(krb5_context context, const krb5_principal principal, @@ -831,6 +838,7 @@ krb5_524_conv_principal(krb5_context context, const char *n, *i, *r; char tmpinst[40]; int type = princ_type(principal); + const int aname_sz = 40; r = principal->realm; @@ -866,15 +874,12 @@ krb5_524_conv_principal(krb5_context context, i = tmpinst; } - if(strlen(r) >= 40) + if (strlcpy (name, n, aname_sz) >= aname_sz) return KRB5_PARSE_MALFORMED; - if(strlen(n) >= 40) + if (strlcpy (instance, r, aname_sz) >= aname_sz) return KRB5_PARSE_MALFORMED; - if(strlen(i) >= 40) + if (strlcpy (realm, r, aname_sz) >= aname_sz) return KRB5_PARSE_MALFORMED; - strcpy(realm, r); - strcpy(name, n); - strcpy(instance, i); return 0; }