From 9c3c8eb191168eec551230422856ba0f8888f533 Mon Sep 17 00:00:00 2001 From: djm Date: Sun, 23 Apr 2006 02:05:46 +0000 Subject: [PATCH] - djm@cvs.openbsd.org 2006/04/03 07:10:38 [gss-genr.c] GSSAPI buffers shouldn't be nul-terminated, spotted in bugzilla #1066 by dleonard AT vintela.com. use xasprintf() to simplify code while in there; "looks right" deraadt@ --- ChangeLog | 5 +++++ gss-genr.c | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 359b003a..e48dfe0e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,11 @@ - dtucker@cvs.openbsd.org 2006/04/02 08:34:52 [ssh-keysign.c] sessionid can be 32 bytes now too when sha256 kex is used; ok djm@ + - djm@cvs.openbsd.org 2006/04/03 07:10:38 + [gss-genr.c] + GSSAPI buffers shouldn't be nul-terminated, spotted in bugzilla #1066 + by dleonard AT vintela.com. use xasprintf() to simplify code while in + there; "looks right" deraadt@ 20060421 - (djm) [Makefile.in configure.ac session.c sshpty.c] diff --git a/gss-genr.c b/gss-genr.c index 4c10f1aa..3d630ab8 100644 --- a/gss-genr.c +++ b/gss-genr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gss-genr.c,v 1.9 2006/03/25 22:22:43 djm Exp $ */ +/* $OpenBSD: gss-genr.c,v 1.10 2006/04/03 07:10:38 djm Exp $ */ /* * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. @@ -205,10 +205,11 @@ OM_uint32 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))) -- 2.45.2