817071d
diff --git a/ChangeLog b/ChangeLog
817071d
index 928999d..3887495 100644
817071d
--- a/ChangeLog
817071d
+++ b/ChangeLog
817071d
@@ -1,3 +1,10 @@
817071d
+20140703
817071d
+ - OpenBSD CVS Sync
817071d
+   - djm@cvs.openbsd.org 2014/07/03 03:34:09
817071d
+     [gss-serv.c session.c ssh-keygen.c]
817071d
+     standardise on NI_MAXHOST for gethostname() string lengths; about
817071d
+     1/2 the cases were using it already. Fixes bz#2239 en passant
817071d
+
817071d
 20140420
817071d
  - (djm) [bufaux.c compat.c compat.h sshconnect2.c sshd.c version.h]
817071d
    OpenSSH 6.5 and 6.6 sometimes encode a value used in the curve25519
817071d
diff --git a/gss-serv.c b/gss-serv.c
817071d
index 14f540e..29916d3 100644
817071d
--- a/gss-serv.c
817071d
+++ b/gss-serv.c
817071d
@@ -1,4 +1,4 @@
817071d
-/* $OpenBSD: gss-serv.c,v 1.26 2014/02/26 20:28:44 djm Exp $ */
817071d
+/* $OpenBSD: gss-serv.c,v 1.27 2014/07/03 03:34:09 djm Exp $ */
817071d
 
817071d
 /*
817071d
  * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
817071d
@@ -102,14 +102,14 @@ static OM_uint32
817071d
 ssh_gssapi_acquire_cred(Gssctxt *ctx)
817071d
 {
817071d
 	OM_uint32 status;
817071d
-	char lname[MAXHOSTNAMELEN];
817071d
+	char lname[NI_MAXHOST];
817071d
 	gss_OID_set oidset;
817071d
 
817071d
 	if (options.gss_strict_acceptor) {
817071d
 		gss_create_empty_oid_set(&status, &oidset);
817071d
 		gss_add_oid_set_member(&status, ctx->oid, &oidset);
817071d
 
817071d
-		if (gethostname(lname, MAXHOSTNAMELEN)) {
817071d
+		if (gethostname(lname, sizeof(lname))) {
817071d
 			gss_release_oid_set(&status, &oidset);
817071d
 			return (-1);
817071d
 		}
817071d
diff --git a/session.c b/session.c
817071d
index ba4589b..e4add93 100644
817071d
--- a/session.c
817071d
+++ b/session.c
817071d
@@ -49,6 +49,7 @@
817071d
 #include <errno.h>
817071d
 #include <fcntl.h>
817071d
 #include <grp.h>
817071d
+#include <netdb.h>
817071d
 #ifdef HAVE_PATHS_H
817071d
 #include <paths.h>
817071d
 #endif
817071d
@@ -2669,7 +2670,7 @@ session_setup_x11fwd(Session *s)
817071d
 {
817071d
 	struct stat st;
817071d
 	char display[512], auth_display[512];
817071d
-	char hostname[MAXHOSTNAMELEN];
817071d
+	char hostname[NI_MAXHOST];
817071d
 	u_int i;
817071d
 
817071d
 	if (no_x11_forwarding_flag) {
817071d
diff --git a/ssh-keygen.c b/ssh-keygen.c
817071d
index 482dc1c..66198e6 100644
817071d
--- a/ssh-keygen.c
817071d
+++ b/ssh-keygen.c
817071d
@@ -165,7 +165,7 @@ int rounds = 0;
817071d
 /* argv0 */
817071d
 extern char *__progname;
817071d
 
817071d
-char hostname[MAXHOSTNAMELEN];
817071d
+char hostname[NI_MAXHOST];
817071d
 
817071d
 /* moduli.c */
817071d
 int gen_candidates(FILE *, u_int32_t, u_int32_t, BIGNUM *);