summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/misc.c b/misc.c
index c4ca12560..bdc06fdb3 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.c,v 1.132 2018/10/03 06:38:35 djm Exp $ */ 1/* $OpenBSD: misc.c,v 1.133 2018/10/05 14:26:09 naddy Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved. 4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved.
@@ -50,6 +50,7 @@
50#include <netinet/in_systm.h> 50#include <netinet/in_systm.h>
51#include <netinet/ip.h> 51#include <netinet/ip.h>
52#include <netinet/tcp.h> 52#include <netinet/tcp.h>
53#include <arpa/inet.h>
53 54
54#include <ctype.h> 55#include <ctype.h>
55#include <errno.h> 56#include <errno.h>
@@ -332,13 +333,16 @@ pwcopy(struct passwd *pw)
332int 333int
333a2port(const char *s) 334a2port(const char *s)
334{ 335{
336 struct servent *se;
335 long long port; 337 long long port;
336 const char *errstr; 338 const char *errstr;
337 339
338 port = strtonum(s, 0, 65535, &errstr); 340 port = strtonum(s, 0, 65535, &errstr);
339 if (errstr != NULL) 341 if (errstr == NULL)
340 return -1; 342 return (int)port;
341 return (int)port; 343 if ((se = getservbyname(s, "tcp")) != NULL)
344 return ntohs(se->s_port);
345 return -1;
342} 346}
343 347
344int 348int