summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1999-07-03 18:24:14 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1999-07-03 18:24:14 +0000
commit009d65a7cb3b2c78febc1fff61f40149c48d061d (patch)
tree8b710a4a6eca79c32fa75ff4d6adc6347bdff241 /libexec
parent534718e4140056ce93b2c36e64582448013c95b9 (diff)
use getnameinfo()
Diffstat (limited to 'libexec')
-rw-r--r--libexec/fingerd/fingerd.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/libexec/fingerd/fingerd.c b/libexec/fingerd/fingerd.c
index 26ded731aca..776b43b952a 100644
--- a/libexec/fingerd/fingerd.c
+++ b/libexec/fingerd/fingerd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fingerd.c,v 1.13 1999/02/24 17:00:01 aaron Exp $ */
+/* $OpenBSD: fingerd.c,v 1.14 1999/07/03 18:24:13 deraadt Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "from: @(#)fingerd.c 8.1 (Berkeley) 6/4/93";
#else
-static char rcsid[] = "$OpenBSD: fingerd.c,v 1.13 1999/02/24 17:00:01 aaron Exp $";
+static char rcsid[] = "$OpenBSD: fingerd.c,v 1.14 1999/07/03 18:24:13 deraadt Exp $";
#endif
#endif /* not lint */
@@ -74,6 +74,7 @@ main(argc, argv)
size_t linesiz;
#define ENTRIES 50
char **ap, *av[ENTRIES + 1], **comp, *line, *prog, *lp, *hname;
+ char hostbuf[MAXHOSTNAMELEN];
prog = _PATH_FINGER;
logging = secure = user_required = short_list = 0;
@@ -112,20 +113,15 @@ main(argc, argv)
}
if (logging) {
- struct hostent *hp;
- struct sockaddr_in sin;
+ struct sockaddr_storage ss;
int sval;
- sval = sizeof(sin);
- if (getpeername(0, (struct sockaddr *)&sin, &sval) < 0)
+ sval = sizeof(ss);
+ if (getpeername(0, (struct sockaddr *)&ss, &sval) < 0)
err("getpeername: %s", strerror(errno));
- if ((hp = gethostbyaddr((char *)&sin.sin_addr.s_addr,
- sizeof(sin.sin_addr.s_addr), AF_INET)))
- hname = strdup(hp->h_name);
- else
- hname = strdup(inet_ntoa(sin.sin_addr));
- if (hname == NULL)
- err("Out of memory");
+ (void)getnameinfo((struct sockaddr *)&ss, ss.ss_len,
+ hostbuf, sizeof(hostbuf), NULL, 0, 0);
+ hname = hostbuf;
}
if ((lp = fgetln(stdin, &linesiz)) == NULL) {