summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2012-09-24 18:46:45 -0700
committerRuss Allbery <rra@stanford.edu>2012-09-24 18:51:36 -0700
commit8148ae765be361e98e1260dcb02b98b3258cf91a (patch)
tree0257fbc50657c83e0ceb010b6f304da6bb0ee6bd /client
parent278348b6e22922fd41d92a62224d293b05244573 (diff)
Prefer asprintf to malloc/strlcpy in client/open.c
Change-Id: I4e9051266824717d3622faa897d0893dbfa9158c
Diffstat (limited to 'client')
-rw-r--r--client/open.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/client/open.c b/client/open.c
index 6852fc0..14382c1 100644
--- a/client/open.c
+++ b/client/open.c
@@ -84,7 +84,6 @@ internal_import_name(struct remctl *r, const char *host,
{
gss_buffer_desc name_buffer;
char *defprinc = NULL;
- size_t length;
OM_uint32 major, minor;
gss_OID oid;
@@ -93,15 +92,11 @@ internal_import_name(struct remctl *r, const char *host,
* dies on failure and that's rude for a library.
*/
if (principal == NULL) {
- length = strlen("host@") + strlen(host) + 1;
- defprinc = malloc(length);
- if (defprinc == NULL) {
+ if (asprintf(&defprinc, "host@%s", host) < 0) {
internal_set_error(r, "cannot allocate memory: %s",
strerror(errno));
return false;
}
- strlcpy(defprinc, "host@", length);
- strlcat(defprinc, host, length);
principal = defprinc;
}