summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/misc.c b/misc.c
index 495b0290d..feeacb859 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.c,v 1.4 2001/02/28 17:52:54 deraadt Exp $ */ 1/* $OpenBSD: misc.c,v 1.5 2001/04/12 20:09:37 stevesk Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -25,7 +25,7 @@
25 */ 25 */
26 26
27#include "includes.h" 27#include "includes.h"
28RCSID("$OpenBSD: misc.c,v 1.4 2001/02/28 17:52:54 deraadt Exp $"); 28RCSID("$OpenBSD: misc.c,v 1.5 2001/04/12 20:09:37 stevesk Exp $");
29 29
30#include "misc.h" 30#include "misc.h"
31#include "log.h" 31#include "log.h"
@@ -116,6 +116,21 @@ pwcopy(struct passwd *pw)
116 return copy; 116 return copy;
117} 117}
118 118
119int a2port(const char *s)
120{
121 long port;
122 char *endp;
123
124 errno = 0;
125 port = strtol(s, &endp, 0);
126 if (s == endp || *endp != '\0' ||
127 (errno == ERANGE && (port == LONG_MIN || port == LONG_MAX)) ||
128 port <= 0 || port > 65535)
129 return 0;
130
131 return port;
132}
133
119mysig_t 134mysig_t
120mysignal(int sig, mysig_t act) 135mysignal(int sig, mysig_t act)
121{ 136{