summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-04-12 23:39:26 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-04-12 23:39:26 +0000
commit19066a112baff6107781dc337b27e557f43098c2 (patch)
tree55200517aa7e6912f8d623b4b8ef340dc9de6495 /misc.c
parentd69dab3cde47c7e17382de556449bfda0fb28deb (diff)
- stevesk@cvs.openbsd.org 2001/04/12 20:09:38
[misc.c misc.h readconf.c servconf.c ssh.c sshd.c] robust port validation; ok markus@ jakob@
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 495b0290..feeacb85 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.4 2001/02/28 17:52:54 deraadt Exp $ */
+/* $OpenBSD: misc.c,v 1.5 2001/04/12 20:09:37 stevesk Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -25,7 +25,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: misc.c,v 1.4 2001/02/28 17:52:54 deraadt Exp $");
+RCSID("$OpenBSD: misc.c,v 1.5 2001/04/12 20:09:37 stevesk Exp $");
#include "misc.h"
#include "log.h"
@@ -116,6 +116,21 @@ pwcopy(struct passwd *pw)
return copy;
}
+int a2port(const char *s)
+{
+ long port;
+ char *endp;
+
+ errno = 0;
+ port = strtol(s, &endp, 0);
+ if (s == endp || *endp != '\0' ||
+ (errno == ERANGE && (port == LONG_MIN || port == LONG_MAX)) ||
+ port <= 0 || port > 65535)
+ return 0;
+
+ return port;
+}
+
mysig_t
mysignal(int sig, mysig_t act)
{