diff options
author | Darren Tucker <dtucker@zip.com.au> | 2011-09-29 23:17:18 +1000 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2011-09-29 23:17:18 +1000 |
commit | b54f50e5d0053e2c79fbb5032722aca541fdc6c1 (patch) | |
tree | 327801f832c83ec725dbe937a74aa94049731471 | |
parent | 5ffe1c4b437a519c90b2017ce8afeef0f845207c (diff) |
- (dtucker) [configure.ac openbsd-compat/Makefile.in
openbsd-compat/strnlen.c] Add strnlen to the compat library.
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | configure.ac | 50 | ||||
-rw-r--r-- | openbsd-compat/Makefile.in | 4 | ||||
-rw-r--r-- | openbsd-compat/strnlen.c | 37 |
4 files changed, 89 insertions, 4 deletions
@@ -1,6 +1,8 @@ | |||
1 | 20110929 | 1 | 20110929 |
2 | - (djm) [configure.ac defines.h] No need to detect sizeof(char); patch | 2 | - (djm) [configure.ac defines.h] No need to detect sizeof(char); patch |
3 | from des AT des.no | 3 | from des AT des.no |
4 | - (dtucker) [configure.ac openbsd-compat/Makefile.in | ||
5 | openbsd-compat/strnlen.c] Add strnlen to the compat library. | ||
4 | 6 | ||
5 | 20110923 | 7 | 20110923 |
6 | - (djm) [openbsd-compat/getcwd.c] Remove OpenBSD rcsid marker since we no | 8 | - (djm) [openbsd-compat/getcwd.c] Remove OpenBSD rcsid marker since we no |
diff --git a/configure.ac b/configure.ac index 38e260ce7..95a2a8d1d 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -1,4 +1,4 @@ | |||
1 | # $Id: configure.ac,v 1.481 2011/09/29 01:11:55 djm Exp $ | 1 | # $Id: configure.ac,v 1.482 2011/09/29 13:17:21 dtucker Exp $ |
2 | # | 2 | # |
3 | # Copyright (c) 1999-2004 Damien Miller | 3 | # Copyright (c) 1999-2004 Damien Miller |
4 | # | 4 | # |
@@ -15,7 +15,7 @@ | |||
15 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 15 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
16 | 16 | ||
17 | AC_INIT([OpenSSH], [Portable], [openssh-unix-dev@mindrot.org]) | 17 | AC_INIT([OpenSSH], [Portable], [openssh-unix-dev@mindrot.org]) |
18 | AC_REVISION($Revision: 1.481 $) | 18 | AC_REVISION($Revision: 1.482 $) |
19 | AC_CONFIG_SRCDIR([ssh.c]) | 19 | AC_CONFIG_SRCDIR([ssh.c]) |
20 | AC_LANG([C]) | 20 | AC_LANG([C]) |
21 | 21 | ||
@@ -1501,6 +1501,7 @@ AC_CHECK_FUNCS([ \ | |||
1501 | strlcat \ | 1501 | strlcat \ |
1502 | strlcpy \ | 1502 | strlcpy \ |
1503 | strmode \ | 1503 | strmode \ |
1504 | strnlen \ | ||
1504 | strnvis \ | 1505 | strnvis \ |
1505 | strptime \ | 1506 | strptime \ |
1506 | strtonum \ | 1507 | strtonum \ |
@@ -2505,6 +2506,51 @@ elif test "x$sandbox_arg" = "xrlimit" || \ | |||
2505 | AC_MSG_ERROR([rlimit sandbox requires setrlimit function]) | 2506 | AC_MSG_ERROR([rlimit sandbox requires setrlimit function]) |
2506 | SANDBOX_STYLE="rlimit" | 2507 | SANDBOX_STYLE="rlimit" |
2507 | AC_DEFINE([SANDBOX_RLIMIT], [1], [Sandbox using setrlimit(2)]) | 2508 | AC_DEFINE([SANDBOX_RLIMIT], [1], [Sandbox using setrlimit(2)]) |
2509 | |||
2510 | AC_MSG_CHECKING([if select works with zero available fds]) | ||
2511 | AC_RUN_IFELSE( | ||
2512 | [AC_LANG_PROGRAM([[ | ||
2513 | #include <sys/time.h> | ||
2514 | #ifdef HAVE_SYS_SELECT_H | ||
2515 | #include <sys/select.h> | ||
2516 | #endif | ||
2517 | #ifdef HAVE_SYS_STAT_H | ||
2518 | #include <sys/stat.h> | ||
2519 | #endif | ||
2520 | #include <sys/resource.h> | ||
2521 | #include <errno.h> | ||
2522 | #include <fcntl.h> | ||
2523 | #include <stdio.h> | ||
2524 | #include <stdlib.h> | ||
2525 | ]], [[ | ||
2526 | struct rlimit rl_zero; | ||
2527 | int fd, r; | ||
2528 | fd_set fds; | ||
2529 | |||
2530 | fd = open("/dev/null", O_RDWR); | ||
2531 | rl_zero.rlim_cur = rl_zero.rlim_max = 0; | ||
2532 | setrlimit(RLIMIT_FSIZE, &rl_zero); | ||
2533 | setrlimit(RLIMIT_NOFILE, &rl_zero); | ||
2534 | FD_ZERO(&fds); | ||
2535 | FD_SET(fd, &fds); | ||
2536 | r = select(fd+1, &fds, NULL, NULL, NULL); | ||
2537 | if (r == -1) | ||
2538 | exit(1); | ||
2539 | exit(0); | ||
2540 | ]])], [ | ||
2541 | AC_MSG_RESULT(yes) | ||
2542 | AC_DEFINE([SELECT_REQUIRED_FDS], [0], | ||
2543 | [number of available fds required for select]) | ||
2544 | ], [ | ||
2545 | AC_MSG_RESULT(no) | ||
2546 | AC_DEFINE([SELECT_REQUIRED_FDS], [1], | ||
2547 | [number of available fds required for select]) | ||
2548 | ], [ | ||
2549 | AC_MSG_RESULT([cross-compiling, assuming yes]) | ||
2550 | AC_DEFINE([SELECT_REQUIRED_FDS], [0], | ||
2551 | [assuming select works with zero free fds]) | ||
2552 | ] | ||
2553 | ) | ||
2508 | elif test -z "$sandbox_arg" || test "x$sandbox_arg" = "xno" || \ | 2554 | elif test -z "$sandbox_arg" || test "x$sandbox_arg" = "xno" || \ |
2509 | test "x$sandbox_arg" = "xnone" || test "x$sandbox_arg" = "xnull" ; then | 2555 | test "x$sandbox_arg" = "xnone" || test "x$sandbox_arg" = "xnull" ; then |
2510 | SANDBOX_STYLE="none" | 2556 | SANDBOX_STYLE="none" |
diff --git a/openbsd-compat/Makefile.in b/openbsd-compat/Makefile.in index 41b22d837..fcc70fca5 100644 --- a/openbsd-compat/Makefile.in +++ b/openbsd-compat/Makefile.in | |||
@@ -1,4 +1,4 @@ | |||
1 | # $Id: Makefile.in,v 1.46 2010/10/07 11:19:24 djm Exp $ | 1 | # $Id: Makefile.in,v 1.47 2011/09/29 13:17:22 dtucker 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 fmt_scaled.o getcwd.o getgrouplist.o getopt.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o pwcache.o readpassphrase.o realpath.o rresvport.o setenv.o setproctitle.o sha2.o sigact.o strlcat.o strlcpy.o strmode.o strptime.o strsep.o strtonum.o strtoll.o strtoul.o timingsafe_bcmp.o vis.o | 19 | OPENBSD=base64.o basename.o bindresvport.o daemon.o dirname.o fmt_scaled.o getcwd.o getgrouplist.o getopt.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o pwcache.o readpassphrase.o realpath.o rresvport.o setenv.o setproctitle.o sha2.o sigact.o strlcat.o strlcpy.o strmode.o strnlen.o strptime.o strsep.o strtonum.o strtoll.o strtoul.o timingsafe_bcmp.o vis.o |
20 | 20 | ||
21 | COMPAT=bsd-arc4random.o bsd-asprintf.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-poll.o bsd-snprintf.o bsd-statvfs.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xmmap.o xcrypt.o | 21 | COMPAT=bsd-arc4random.o bsd-asprintf.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-poll.o bsd-snprintf.o bsd-statvfs.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xmmap.o xcrypt.o |
22 | 22 | ||
diff --git a/openbsd-compat/strnlen.c b/openbsd-compat/strnlen.c new file mode 100644 index 000000000..93d515595 --- /dev/null +++ b/openbsd-compat/strnlen.c | |||
@@ -0,0 +1,37 @@ | |||
1 | /* $OpenBSD: strnlen.c,v 1.3 2010/06/02 12:58:12 millert Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 2010 Todd C. Miller <Todd.Miller@courtesan.com> | ||
5 | * | ||
6 | * Permission to use, copy, modify, and distribute this software for any | ||
7 | * purpose with or without fee is hereby granted, provided that the above | ||
8 | * copyright notice and this permission notice appear in all copies. | ||
9 | * | ||
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
17 | */ | ||
18 | |||
19 | /* OPENBSD ORIGINAL: lib/libc/string/strnlen.c */ | ||
20 | |||
21 | #include "config.h" | ||
22 | #ifndef HAVE_STRNLEN | ||
23 | #include <sys/types.h> | ||
24 | |||
25 | #include <string.h> | ||
26 | |||
27 | size_t | ||
28 | strnlen(const char *str, size_t maxlen) | ||
29 | { | ||
30 | const char *cp; | ||
31 | |||
32 | for (cp = str; maxlen != 0 && *cp != '\0'; cp++, maxlen--) | ||
33 | ; | ||
34 | |||
35 | return (size_t)(cp - str); | ||
36 | } | ||
37 | #endif | ||