diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | configure.ac | 13 | ||||
-rw-r--r-- | openbsd-compat/Makefile.in | 4 | ||||
-rw-r--r-- | openbsd-compat/openbsd-compat.h | 6 | ||||
-rw-r--r-- | openbsd-compat/strtonum.c | 69 |
5 files changed, 93 insertions, 6 deletions
@@ -104,6 +104,11 @@ | |||
104 | - (dtucker) [configure.ac openbsd-compat/getrrsetbyname.c] Bug #1033: Provide | 104 | - (dtucker) [configure.ac openbsd-compat/getrrsetbyname.c] Bug #1033: Provide |
105 | templates for _getshort and _getlong if missing to prevent compiler warnings | 105 | templates for _getshort and _getlong if missing to prevent compiler warnings |
106 | on Linux. | 106 | on Linux. |
107 | - (djm) [configure.ac openbsd-compat/Makefile.in] | ||
108 | [openbsd-compat/openbsd-compat.h openbsd-compat/strtonum.c] | ||
109 | Add strtonum(3) from OpenBSD libc, new code needs it. | ||
110 | Unfortunately Linux forces us to do a bizarre dance with compiler | ||
111 | options to get LLONG_MIN/MAX; Spotted by and ok dtucker@ | ||
107 | 112 | ||
108 | 20050524 | 113 | 20050524 |
109 | - (djm) [contrib/caldera/openssh.spec contrib/redhat/openssh.spec] | 114 | - (djm) [contrib/caldera/openssh.spec contrib/redhat/openssh.spec] |
@@ -2603,4 +2608,4 @@ | |||
2603 | - (djm) Trim deprecated options from INSTALL. Mention UsePAM | 2608 | - (djm) Trim deprecated options from INSTALL. Mention UsePAM |
2604 | - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu | 2609 | - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu |
2605 | 2610 | ||
2606 | $Id: ChangeLog,v 1.3789 2005/05/26 10:12:15 dtucker Exp $ | 2611 | $Id: ChangeLog,v 1.3790 2005/05/26 10:48:25 djm Exp $ |
diff --git a/configure.ac b/configure.ac index fd8218aea..58a3ff47d 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -1,4 +1,4 @@ | |||
1 | # $Id: configure.ac,v 1.261 2005/05/26 10:12:15 dtucker Exp $ | 1 | # $Id: configure.ac,v 1.262 2005/05/26 10:48:25 djm Exp $ |
2 | # | 2 | # |
3 | # Copyright (c) 1999-2004 Damien Miller | 3 | # Copyright (c) 1999-2004 Damien Miller |
4 | # | 4 | # |
@@ -79,6 +79,15 @@ AC_SUBST(LD) | |||
79 | AC_C_INLINE | 79 | AC_C_INLINE |
80 | if test "$GCC" = "yes" || test "$GCC" = "egcs"; then | 80 | if test "$GCC" = "yes" || test "$GCC" = "egcs"; then |
81 | CFLAGS="$CFLAGS -Wall -Wpointer-arith -Wno-uninitialized" | 81 | CFLAGS="$CFLAGS -Wall -Wpointer-arith -Wno-uninitialized" |
82 | |||
83 | # Check for -std=gnu99 support (needed for LLONG_MIN/MAX on Linux) | ||
84 | saved_CFLAGS="$CFLAGS" | ||
85 | CFLAGS="$CFLAGS -std=gnu99" | ||
86 | AC_MSG_CHECKING(whether cc accepts -std=gnu99 option) | ||
87 | AC_TRY_COMPILE([], [return(0);], [AC_MSG_RESULT(yes)], | ||
88 | [AC_MSG_RESULT(no) | ||
89 | CFLAGS="$saved_CFLAGS"], | ||
90 | ) | ||
82 | fi | 91 | fi |
83 | 92 | ||
84 | AC_ARG_WITH(rpath, | 93 | AC_ARG_WITH(rpath, |
@@ -922,7 +931,7 @@ AC_CHECK_FUNCS(\ | |||
922 | setdtablesize setegid setenv seteuid setgroups setlogin setpcred \ | 931 | setdtablesize setegid setenv seteuid setgroups setlogin setpcred \ |
923 | setproctitle setregid setreuid setrlimit \ | 932 | setproctitle setregid setreuid setrlimit \ |
924 | setsid setvbuf sigaction sigvec snprintf socketpair strerror \ | 933 | setsid setvbuf sigaction sigvec snprintf socketpair strerror \ |
925 | strlcat strlcpy strmode strnvis strtoul sysconf tcgetpgrp \ | 934 | strlcat strlcpy strmode strnvis strtonum strtoul sysconf tcgetpgrp \ |
926 | truncate unsetenv updwtmpx utimes vhangup vsnprintf waitpid \ | 935 | truncate unsetenv updwtmpx utimes vhangup vsnprintf waitpid \ |
927 | ) | 936 | ) |
928 | 937 | ||
diff --git a/openbsd-compat/Makefile.in b/openbsd-compat/Makefile.in index 0f34f2240..8368aa2ce 100644 --- a/openbsd-compat/Makefile.in +++ b/openbsd-compat/Makefile.in | |||
@@ -1,4 +1,4 @@ | |||
1 | # $Id: Makefile.in,v 1.31 2004/08/15 08:41:00 djm Exp $ | 1 | # $Id: Makefile.in,v 1.32 2005/05/26 10:48:25 djm Exp $ |
2 | 2 | ||
3 | sysconfdir=@sysconfdir@ | 3 | sysconfdir=@sysconfdir@ |
4 | piddir=@piddir@ | 4 | piddir=@piddir@ |
@@ -16,7 +16,7 @@ RANLIB=@RANLIB@ | |||
16 | INSTALL=@INSTALL@ | 16 | INSTALL=@INSTALL@ |
17 | LDFLAGS=-L. @LDFLAGS@ | 17 | LDFLAGS=-L. @LDFLAGS@ |
18 | 18 | ||
19 | OPENBSD=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 | 19 | OPENBSD=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 strtonum.o strtoul.o vis.o |
20 | 20 | ||
21 | COMPAT=bsd-arc4random.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-snprintf.o bsd-waitpid.o fake-rfc2553.o xmmap.o xcrypt.o | 21 | COMPAT=bsd-arc4random.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-snprintf.o bsd-waitpid.o fake-rfc2553.o xmmap.o xcrypt.o |
22 | 22 | ||
diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h index 89d1454e0..a4cfa6c4d 100644 --- a/openbsd-compat/openbsd-compat.h +++ b/openbsd-compat/openbsd-compat.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $Id: openbsd-compat.h,v 1.26 2004/08/15 08:41:00 djm Exp $ */ | 1 | /* $Id: openbsd-compat.h,v 1.27 2005/05/26 10:48:25 djm Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 1999-2003 Damien Miller. All rights reserved. | 4 | * Copyright (c) 1999-2003 Damien Miller. All rights reserved. |
@@ -152,6 +152,10 @@ int openpty(int *, int *, char *, struct termios *, struct winsize *); | |||
152 | int snprintf(char *, size_t, const char *, ...); | 152 | int snprintf(char *, size_t, const char *, ...); |
153 | #endif | 153 | #endif |
154 | 154 | ||
155 | #ifndef HAVE_STRTONUM | ||
156 | long long strtonum(const char *, long long, long long, const char **); | ||
157 | #endif | ||
158 | |||
155 | #ifndef HAVE_VSNPRINTF | 159 | #ifndef HAVE_VSNPRINTF |
156 | int vsnprintf(char *, size_t, const char *, va_list); | 160 | int vsnprintf(char *, size_t, const char *, va_list); |
157 | #endif | 161 | #endif |
diff --git a/openbsd-compat/strtonum.c b/openbsd-compat/strtonum.c new file mode 100644 index 000000000..b681ed83b --- /dev/null +++ b/openbsd-compat/strtonum.c | |||
@@ -0,0 +1,69 @@ | |||
1 | /* OPENBSD ORIGINAL: lib/libc/stdlib/strtonum.c */ | ||
2 | |||
3 | /* $OpenBSD: strtonum.c,v 1.6 2004/08/03 19:38:01 millert Exp $ */ | ||
4 | |||
5 | /* | ||
6 | * Copyright (c) 2004 Ted Unangst and Todd Miller | ||
7 | * All rights reserved. | ||
8 | * | ||
9 | * Permission to use, copy, modify, and distribute this software for any | ||
10 | * purpose with or without fee is hereby granted, provided that the above | ||
11 | * copyright notice and this permission notice appear in all copies. | ||
12 | * | ||
13 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
14 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
15 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
16 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
17 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
18 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
19 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
20 | */ | ||
21 | |||
22 | #include "includes.h" | ||
23 | #ifndef HAVE_STRTONUM | ||
24 | #include <limits.h> | ||
25 | |||
26 | #define INVALID 1 | ||
27 | #define TOOSMALL 2 | ||
28 | #define TOOLARGE 3 | ||
29 | |||
30 | long long | ||
31 | strtonum(const char *numstr, long long minval, long long maxval, | ||
32 | const char **errstrp) | ||
33 | { | ||
34 | long long ll = 0; | ||
35 | char *ep; | ||
36 | int error = 0; | ||
37 | struct errval { | ||
38 | const char *errstr; | ||
39 | int err; | ||
40 | } ev[4] = { | ||
41 | { NULL, 0 }, | ||
42 | { "invalid", EINVAL }, | ||
43 | { "too small", ERANGE }, | ||
44 | { "too large", ERANGE }, | ||
45 | }; | ||
46 | |||
47 | ev[0].err = errno; | ||
48 | errno = 0; | ||
49 | if (minval > maxval) | ||
50 | error = INVALID; | ||
51 | else { | ||
52 | ll = strtoll(numstr, &ep, 10); | ||
53 | if (numstr == ep || *ep != '\0') | ||
54 | error = INVALID; | ||
55 | else if ((ll == LLONG_MIN && errno == ERANGE) || ll < minval) | ||
56 | error = TOOSMALL; | ||
57 | else if ((ll == LLONG_MAX && errno == ERANGE) || ll > maxval) | ||
58 | error = TOOLARGE; | ||
59 | } | ||
60 | if (errstrp != NULL) | ||
61 | *errstrp = ev[error].errstr; | ||
62 | errno = ev[error].err; | ||
63 | if (error) | ||
64 | ll = 0; | ||
65 | |||
66 | return (ll); | ||
67 | } | ||
68 | |||
69 | #endif /* HAVE_STRTONUM */ | ||