At some point, construct_utmp() was changed to use realhostname() to fill

in the struct utmp due to concerns about the length of the hostname buffer.
However, this breaks the UseDNS option.  There is a simpler and better
solution: initialize utmp_len to the correct value (UT_HOSTSIZE instead of
MAXHOSTNAMELEN) and let get_remote_name_or_ip() worry about the size of the
buffer.

PR:		bin/97499
Submitted by:	Bruce Cran <bruce@cran.org.uk>
MFC after:	1 week
This commit is contained in:
Dag-Erling Smørgrav 2008-10-21 11:58:26 +00:00
parent 3ba28ace77
commit 0aeb000d7b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=184122
2 changed files with 4 additions and 4 deletions

View File

@ -146,7 +146,6 @@
*/
#include "includes.h"
__RCSID("$FreeBSD$");
#include <sys/types.h>
#include <sys/stat.h>
@ -689,8 +688,8 @@ construct_utmp(struct logininfo *li,
strncpy(ut->ut_name, li->username,
MIN_SIZEOF(ut->ut_name, li->username));
# ifdef HAVE_HOST_IN_UTMP
realhostname_sa(ut->ut_host, sizeof ut->ut_host,
&li->hostaddr.sa, li->hostaddr.sa.sa_len);
strncpy(ut->ut_host, li->hostname,
MIN_SIZEOF(ut->ut_host, li->hostname));
# endif
# ifdef HAVE_ADDR_IN_UTMP
/* this is just a 32-bit IP address */

View File

@ -72,6 +72,7 @@ __RCSID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <utmp.h>
#include <openssl/dh.h>
#include <openssl/bn.h>
@ -238,7 +239,7 @@ u_char *session_id2 = NULL;
u_int session_id2_len = 0;
/* record remote hostname or ip */
u_int utmp_len = MAXHOSTNAMELEN;
u_int utmp_len = UT_HOSTSIZE;
/* options.max_startup sized array of fd ints */
int *startup_pipes = NULL;