diff options
author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2009-02-24 18:49:27 +0000 |
---|---|---|
committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2009-02-24 18:49:27 +0000 |
commit | 9ab1052dcdca9be06dcec8abc37103a70e358e73 (patch) | |
tree | e584c257bb55edd49609ecf2750698017a03411e /misc.c | |
parent | 23371b1d95849b7f55a33cad9ba00f81e822c5a1 (diff) | |
download | src-9ab1052dcdca9be06dcec8abc37103a70e358e73.tar.gz src-9ab1052dcdca9be06dcec8abc37103a70e358e73.zip |
Vendor import of OpenSSH 5.2p1vendor/openssh/5.2p1
Notes
Notes:
svn path=/vendor-crypto/openssh/dist/; revision=189006
svn path=/vendor-crypto/openssh/5.2p1/; revision=189007; tag=vendor/openssh/5.2p1
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 27 |
1 files changed, 12 insertions, 15 deletions
@@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.69 2008/06/13 01:38:23 dtucker Exp $ */ +/* $OpenBSD: misc.c,v 1.71 2009/02/21 19:32:04 tobias Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2005,2006 Damien Miller. All rights reserved. @@ -221,23 +221,19 @@ pwcopy(struct passwd *pw) /* * Convert ASCII string to TCP/IP port number. - * Port must be >0 and <=65535. - * Return 0 if invalid. + * Port must be >=0 and <=65535. + * Return -1 if invalid. */ 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; + long long port; + const char *errstr; - return port; + port = strtonum(s, 0, 65535, &errstr); + if (errstr != NULL) + return -1; + return (int)port; } int @@ -718,7 +714,8 @@ sanitise_stdfd(void) int nullfd, dupfd; if ((nullfd = dupfd = open(_PATH_DEVNULL, O_RDWR)) == -1) { - fprintf(stderr, "Couldn't open /dev/null: %s", strerror(errno)); + fprintf(stderr, "Couldn't open /dev/null: %s\n", + strerror(errno)); exit(1); } while (++dupfd <= 2) { @@ -726,7 +723,7 @@ sanitise_stdfd(void) if (fcntl(dupfd, F_GETFL, 0) >= 0) continue; if (dup2(nullfd, dupfd) == -1) { - fprintf(stderr, "dup2: %s", strerror(errno)); + fprintf(stderr, "dup2: %s\n", strerror(errno)); exit(1); } } |