-/* $OpenBSD: gss-genr.c,v 1.7 2006/03/20 04:07:49 djm Exp $ */
+/* $OpenBSD: gss-genr.c,v 1.11 2006/07/22 20:48:23 stevesk Exp $ */
/*
* Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
#ifdef GSSAPI
+#include <string.h>
+#include <unistd.h>
+
#include "xmalloc.h"
#include "bufaux.h"
#include "log.h"
void
ssh_gssapi_build_ctx(Gssctxt **ctx)
{
- *ctx = xmalloc(sizeof (Gssctxt));
- (*ctx)->major = 0;
- (*ctx)->minor = 0;
+ *ctx = xcalloc(1, sizeof (Gssctxt));
(*ctx)->context = GSS_C_NO_CONTEXT;
(*ctx)->name = GSS_C_NO_NAME;
(*ctx)->oid = GSS_C_NO_OID;
ssh_gssapi_import_name(Gssctxt *ctx, const char *host)
{
gss_buffer_desc gssbuf;
+ char *val;
- gssbuf.length = sizeof("host@") + strlen(host);
- gssbuf.value = xmalloc(gssbuf.length);
- snprintf(gssbuf.value, gssbuf.length, "host@%s", host);
+ xasprintf(&val, "host@%s", host);
+ gssbuf.value = val;
+ gssbuf.length = strlen(gssbuf.value);
if ((ctx->major = gss_import_name(&ctx->minor,
&gssbuf, GSS_C_NT_HOSTBASED_SERVICE, &ctx->name)))