]> andersk Git - openssh.git/commitdiff
- (djm) [configure.ac openbsd-compat/Makefile.in]
authordjm <djm>
Thu, 26 May 2005 10:48:25 +0000 (10:48 +0000)
committerdjm <djm>
Thu, 26 May 2005 10:48:25 +0000 (10:48 +0000)
         [openbsd-compat/openbsd-compat.h openbsd-compat/strtonum.c]
         Add strtonum(3) from OpenBSD libc, new code needs it.
         Unfortunately Linux forces us to do a bizarre dance with compiler
         options to get LLONG_MIN/MAX; Spotted by and ok dtucker@

ChangeLog
configure.ac
openbsd-compat/Makefile.in
openbsd-compat/openbsd-compat.h
openbsd-compat/strtonum.c [new file with mode: 0644]

index 5efd96cd6d174fee6ccbe6921e18d1d0953f59cb..139269370658a417be2ab12971c9d7f87742cb53 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
  - (dtucker) [configure.ac openbsd-compat/getrrsetbyname.c] Bug #1033: Provide
    templates for _getshort and _getlong if missing to prevent compiler warnings
    on Linux.
+ - (djm) [configure.ac openbsd-compat/Makefile.in]
+         [openbsd-compat/openbsd-compat.h openbsd-compat/strtonum.c]
+         Add strtonum(3) from OpenBSD libc, new code needs it. 
+         Unfortunately Linux forces us to do a bizarre dance with compiler
+         options to get LLONG_MIN/MAX; Spotted by and ok dtucker@ 
 
 20050524
  - (djm) [contrib/caldera/openssh.spec contrib/redhat/openssh.spec]
index 057d26ca1bf8c5b6c7d1e3ee26cc860cca9836ca..f9621d1b8379e1647f2438ab5017116a46e76b88 100644 (file)
@@ -79,6 +79,15 @@ AC_SUBST(LD)
 AC_C_INLINE
 if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
        CFLAGS="$CFLAGS -Wall -Wpointer-arith -Wno-uninitialized"
+
+       # Check for -std=gnu99 support (needed for LLONG_MIN/MAX on Linux)
+       saved_CFLAGS="$CFLAGS"
+       CFLAGS="$CFLAGS -std=gnu99"
+       AC_MSG_CHECKING(whether cc accepts -std=gnu99 option)
+       AC_TRY_COMPILE([], [return(0);], [AC_MSG_RESULT(yes)],
+               [AC_MSG_RESULT(no)
+               CFLAGS="$saved_CFLAGS"],
+       )
 fi
 
 AC_ARG_WITH(rpath,
@@ -922,7 +931,7 @@ AC_CHECK_FUNCS(\
        setdtablesize setegid setenv seteuid setgroups setlogin setpcred \
        setproctitle setregid setreuid setrlimit \
        setsid setvbuf sigaction sigvec snprintf socketpair strerror \
-       strlcat strlcpy strmode strnvis strtoul sysconf tcgetpgrp \
+       strlcat strlcpy strmode strnvis strtonum strtoul sysconf tcgetpgrp \
        truncate unsetenv updwtmpx utimes vhangup vsnprintf waitpid \
 )
 
index 5a5255d6eb0a282a57636c02ceba3f3f5eb7459a..395d2885033c47f3cd944040b746c9ca70bcd83a 100644 (file)
@@ -16,7 +16,7 @@ RANLIB=@RANLIB@
 INSTALL=@INSTALL@
 LDFLAGS=-L. @LDFLAGS@
 
-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
+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
 
 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
 
index 76366ffdb8090ac76c11357a40461e32630e0267..8f55193b006f32654d7fe61a6a232fc510f108ae 100644 (file)
@@ -152,6 +152,10 @@ int openpty(int *, int *, char *, struct termios *, struct winsize *);
 int snprintf(char *, size_t, const char *, ...);
 #endif 
 
+#ifndef HAVE_STRTONUM
+long long strtonum(const char *, long long, long long, const char **);
+#endif
+
 #ifndef HAVE_VSNPRINTF
 int vsnprintf(char *, size_t, const char *, va_list);
 #endif
diff --git a/openbsd-compat/strtonum.c b/openbsd-compat/strtonum.c
new file mode 100644 (file)
index 0000000..b681ed8
--- /dev/null
@@ -0,0 +1,69 @@
+/* OPENBSD ORIGINAL: lib/libc/stdlib/strtonum.c */
+
+/*     $OpenBSD: strtonum.c,v 1.6 2004/08/03 19:38:01 millert Exp $    */
+
+/*
+ * Copyright (c) 2004 Ted Unangst and Todd Miller
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "includes.h"
+#ifndef HAVE_STRTONUM
+#include <limits.h>
+
+#define INVALID        1
+#define TOOSMALL       2
+#define TOOLARGE       3
+
+long long
+strtonum(const char *numstr, long long minval, long long maxval,
+    const char **errstrp)
+{
+       long long ll = 0;
+       char *ep;
+       int error = 0;
+       struct errval {
+               const char *errstr;
+               int err;
+       } ev[4] = {
+               { NULL,         0 },
+               { "invalid",    EINVAL },
+               { "too small",  ERANGE },
+               { "too large",  ERANGE },
+       };
+
+       ev[0].err = errno;
+       errno = 0;
+       if (minval > maxval)
+               error = INVALID;
+       else {
+               ll = strtoll(numstr, &ep, 10);
+               if (numstr == ep || *ep != '\0')
+                       error = INVALID;
+               else if ((ll == LLONG_MIN && errno == ERANGE) || ll < minval)
+                       error = TOOSMALL;
+               else if ((ll == LLONG_MAX && errno == ERANGE) || ll > maxval)
+                       error = TOOLARGE;
+       }
+       if (errstrp != NULL)
+               *errstrp = ev[error].errstr;
+       errno = ev[error].err;
+       if (error)
+               ll = 0;
+
+       return (ll);
+}
+
+#endif /* HAVE_STRTONUM */
This page took 0.057074 seconds and 5 git commands to generate.