one less data copy

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9833 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
2001-05-02 09:30:17 +00:00
parent bb5afef553
commit c6ba95904c

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997 - 2000 Kungliga Tekniska H<>gskolan * Copyright (c) 1997 - 2001 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden). * (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved. * All rights reserved.
* *
@@ -49,8 +49,7 @@ krb5_sock_to_principal (krb5_context context,
socklen_t len = sizeof(__ss); socklen_t len = sizeof(__ss);
struct hostent *hostent; struct hostent *hostent;
int family; int family;
char hname[256]; char *hname = NULL;
char *tmp;
if (getsockname (sock, sa, &len) < 0) if (getsockname (sock, sa, &len) < 0)
return errno; return errno;
@@ -64,20 +63,19 @@ krb5_sock_to_principal (krb5_context context,
address.address.length, address.address.length,
family); family);
if (hostent == NULL) if (hostent == NULL)
return h_errno; return krb5_h_errno_to_heim_errno(h_errno);
tmp = hostent->h_name; hname = hostent->h_name;
if (strchr(tmp, '.') == NULL) { if (strchr(hname, '.') == NULL) {
char **a; char **a;
for (a = hostent->h_aliases; a != NULL && *a != NULL; ++a) for (a = hostent->h_aliases; a != NULL && *a != NULL; ++a)
if (strchr(*a, '.') != NULL) { if (strchr(*a, '.') != NULL) {
tmp = *a; hname = *a;
break; break;
} }
} }
strlcpy(hname, tmp, sizeof(hname));
return krb5_sname_to_principal (context, return krb5_sname_to_principal (context,
hname, hname,
sname, sname,