summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--configure.ac4
-rw-r--r--openbsd-compat/Makefile.in4
-rw-r--r--openbsd-compat/strtoul.c112
4 files changed, 119 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index bcca919b4..8ade4e7ea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,8 @@
4 cleanup functions. With & ok djm@ 4 cleanup functions. With & ok djm@
5 - (dtucker) [contrib/redhat/openssh.spec] Bug #714: Now that UsePAM is a 5 - (dtucker) [contrib/redhat/openssh.spec] Bug #714: Now that UsePAM is a
6 run-time switch, always build --with-md5-passwords. 6 run-time switch, always build --with-md5-passwords.
7 - (dtucker) [configure.ac openbsd-compat/Makefile.in openbsd-compat/strtoul.c]
8 Bug #670: add strtoul() to openbsd-compat for platforms lacking it. ok djm@
7 9
820031003 1020031003
9 - (dtucker) OpenBSD CVS Sync 11 - (dtucker) OpenBSD CVS Sync
@@ -1286,4 +1288,4 @@
1286 - Fix sshd BindAddress and -b options for systems using fake-getaddrinfo. 1288 - Fix sshd BindAddress and -b options for systems using fake-getaddrinfo.
1287 Report from murple@murple.net, diagnosis from dtucker@zip.com.au 1289 Report from murple@murple.net, diagnosis from dtucker@zip.com.au
1288 1290
1289$Id: ChangeLog,v 1.3060 2003/10/07 07:40:56 dtucker Exp $ 1291$Id: ChangeLog,v 1.3061 2003/10/07 07:49:56 dtucker Exp $
diff --git a/configure.ac b/configure.ac
index dd22c98d4..02b7e2b82 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
1# $Id: configure.ac,v 1.169 2003/10/02 06:26:34 dtucker Exp $ 1# $Id: configure.ac,v 1.170 2003/10/07 07:49:57 dtucker Exp $
2 2
3AC_INIT 3AC_INIT
4AC_CONFIG_SRCDIR([ssh.c]) 4AC_CONFIG_SRCDIR([ssh.c])
@@ -739,7 +739,7 @@ AC_CHECK_FUNCS(\
739 setdtablesize setegid setenv seteuid setgroups setlogin setpcred \ 739 setdtablesize setegid setenv seteuid setgroups setlogin setpcred \
740 setproctitle setregid setresgid setresuid setreuid setrlimit \ 740 setproctitle setregid setresgid setresuid setreuid setrlimit \
741 setsid setvbuf sigaction sigvec snprintf socketpair strerror \ 741 setsid setvbuf sigaction sigvec snprintf socketpair strerror \
742 strlcat strlcpy strmode strnvis sysconf tcgetpgrp \ 742 strlcat strlcpy strmode strnvis strtoul sysconf tcgetpgrp \
743 truncate utimes vhangup vsnprintf waitpid \ 743 truncate utimes vhangup vsnprintf waitpid \
744) 744)
745 745
diff --git a/openbsd-compat/Makefile.in b/openbsd-compat/Makefile.in
index c48593f7b..de9856eea 100644
--- a/openbsd-compat/Makefile.in
+++ b/openbsd-compat/Makefile.in
@@ -1,4 +1,4 @@
1# $Id: Makefile.in,v 1.28 2003/07/24 06:52:14 mouring Exp $ 1# $Id: Makefile.in,v 1.29 2003/10/07 07:49:57 dtucker Exp $
2 2
3sysconfdir=@sysconfdir@ 3sysconfdir=@sysconfdir@
4piddir=@piddir@ 4piddir=@piddir@
@@ -16,7 +16,7 @@ RANLIB=@RANLIB@
16INSTALL=@INSTALL@ 16INSTALL=@INSTALL@
17LDFLAGS=-L. @LDFLAGS@ 17LDFLAGS=-L. @LDFLAGS@
18 18
19OPENBSD=base64.o basename.o bindresvport.o daemon.o dirname.o getcwd.o getgrouplist.o getopt.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o readpassphrase.o realpath.o rresvport.o setenv.o setproctitle.o sigact.o strlcat.o strlcpy.o strmode.o strsep.o vis.o 19OPENBSD=base64.o basename.o bindresvport.o daemon.o dirname.o getcwd.o getgrouplist.o getopt.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o readpassphrase.o realpath.o rresvport.o setenv.o setproctitle.o sigact.o strlcat.o strlcpy.o strmode.o strsep.o strtoul.o vis.o
20 20
21COMPAT=bsd-arc4random.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-snprintf.o bsd-waitpid.o fake-rfc2553.o xmmap.o xcrypt.o 21COMPAT=bsd-arc4random.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-snprintf.o bsd-waitpid.o fake-rfc2553.o xmmap.o xcrypt.o
22 22
diff --git a/openbsd-compat/strtoul.c b/openbsd-compat/strtoul.c
new file mode 100644
index 000000000..877e6a01f
--- /dev/null
+++ b/openbsd-compat/strtoul.c
@@ -0,0 +1,112 @@
1/*
2 * Copyright (c) 1990 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include "includes.h"
31#ifndef HAVE_STRTOUL
32
33#if defined(LIBC_SCCS) && !defined(lint)
34static char *rcsid = "$OpenBSD: strtoul.c,v 1.5 2003/06/02 20:18:38 millert Exp $";
35#endif /* LIBC_SCCS and not lint */
36
37#include <ctype.h>
38#include <errno.h>
39#include <limits.h>
40#include <stdlib.h>
41
42/*
43 * Convert a string to an unsigned long integer.
44 *
45 * Ignores `locale' stuff. Assumes that the upper and lower case
46 * alphabets and digits are each contiguous.
47 */
48unsigned long
49strtoul(nptr, endptr, base)
50 const char *nptr;
51 char **endptr;
52 register int base;
53{
54 register const char *s;
55 register unsigned long acc, cutoff;
56 register int c;
57 register int neg, any, cutlim;
58
59 /*
60 * See strtol for comments as to the logic used.
61 */
62 s = nptr;
63 do {
64 c = (unsigned char) *s++;
65 } while (isspace(c));
66 if (c == '-') {
67 neg = 1;
68 c = *s++;
69 } else {
70 neg = 0;
71 if (c == '+')
72 c = *s++;
73 }
74 if ((base == 0 || base == 16) &&
75 c == '0' && (*s == 'x' || *s == 'X')) {
76 c = s[1];
77 s += 2;
78 base = 16;
79 }
80 if (base == 0)
81 base = c == '0' ? 8 : 10;
82
83 cutoff = ULONG_MAX / (unsigned long)base;
84 cutlim = ULONG_MAX % (unsigned long)base;
85 for (acc = 0, any = 0;; c = (unsigned char) *s++) {
86 if (isdigit(c))
87 c -= '0';
88 else if (isalpha(c))
89 c -= isupper(c) ? 'A' - 10 : 'a' - 10;
90 else
91 break;
92 if (c >= base)
93 break;
94 if (any < 0)
95 continue;
96 if (acc > cutoff || acc == cutoff && c > cutlim) {
97 any = -1;
98 acc = ULONG_MAX;
99 errno = ERANGE;
100 } else {
101 any = 1;
102 acc *= (unsigned long)base;
103 acc += c;
104 }
105 }
106 if (neg && any > 0)
107 acc = -acc;
108 if (endptr != 0)
109 *endptr = (char *) (any ? s - 1 : nptr);
110 return (acc);
111}
112#endif /* !HAVE_STRTOUL */