Compare commits

..

15 Commits

Author SHA1 Message Date
Guillem Jover
84acf21568 Release libbsd 0.11.6 2022-03-30 23:09:35 +02:00
WANG Xuerui
15200ec7ac Add LoongArch support to nlist()
Closes: !13
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-03-30 23:03:56 +02:00
Guillem Jover
f7465b93ec man: Document when functions were added to musl in libbsd(7)
The explicit_bzero(3) and reallocarray(3) functions are also present on
musl libc, mention it in the superseded section.
2022-03-30 22:58:47 +02:00
Guilherme Janczak
e5ed5fdd62 Remove arc4random() OpenBSD support
The arc4random() support for OpenBSD does not build. The intention was
to include any portability code so that the library could be easily
ported to such systems, but it makes little sense to build it on OpenBSD
where most of the functionality will be already present, or the software
would have been ported anyway.

[guillem@hadrons.org: Reword commit message to add rationale. ]

Closes: !15
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-03-30 22:55:56 +02:00
Duncan Overbruck
abb1a6b1a7 build: Add alpine to CI for tests with musl libc
Closes: !18
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-01-29 15:03:08 +01:00
Guillem Jover
c9ff83687c test: Import explicit_bzero and strtonum test cases from OpenBSD
- Remove trailing spaces.
- Declare file-scope functions and variables static.
- Declare functions with a proper prototype.
- Do not mix declarations and code for C90 conformance.
- Do not compare size_t and ssize_t variables.
2022-01-29 14:54:24 +01:00
Guillem Jover
62e67bb49e build: Sort test programs in .gitignore 2022-01-29 14:52:39 +01:00
Duncan Overbruck
87b1307040 test: Add fpurge() test case using open_memstream(3) FILE
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-01-29 14:10:55 +01:00
Duncan Overbruck
ba3c46b30f fpurge: Make it work with non fd based FILEs
Streams opened with for example open_memstream(3) will have no associated
file descriptor, and fileno(3) will fail.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-01-26 04:42:09 +01:00
Duncan Overbruck
091097e062 test: Remove static FILE declaration from fpurge test
This does not work with libcs that do not declare the structure
in a header file, like musl. And gets in the way of supporting
non-fd based streams.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-01-26 04:39:42 +01:00
Guillem Jover
5f9608c775 Release libbsd 0.11.5 2022-01-25 01:48:29 +01:00
Guillem Jover
eef07993c9 Revert "build: Add missing proctitle unit test program"
This reverts commit beafad2657.

This test was already handled later on as part of the BUILD_LIBBSD_CTOR
conditional. Adding it to the unconditional set made the build fail when
the system does not have GNU .init_array section support.

Closes: #9
Analysis-by: Duncan Overbruck <mail@duncano.de>
2022-01-25 01:41:14 +01:00
Guillem Jover
c6d589bc71 Document how to build from git and from a tarball release
Closes: #8
2022-01-23 21:09:05 +01:00
Guillem Jover
2975d809a0 build: Check for objdump explicitly
We should not assume that something will implicitly check for this tool,
as we need it ourselves, and this is an internal implementation detail
of right now libtool.

Fixes: commit f11ab67223
2022-01-23 20:52:26 +01:00
Sam James
f11ab67223 build: Respect $(OBJDUMP)
We already search for it in `./configure` so let's respect
the result of that search.

This helps with cross-compilation and any other cases
where one might want to choose a different toolchain.

Closes: !16
Bug: https://bugs.gentoo.org/831863
Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-01-23 18:42:01 +01:00
15 changed files with 386 additions and 92 deletions

View File

@@ -1,19 +1,37 @@
image: debian:buster
before_script:
- apt-get update -qq
- apt-get install -qq -y --no-install-recommends
git gcc make autoconf automake libtool libmd-dev gcovr
unit-tests:
stage: test
.unit-tests:
script:
- ./autogen && ./configure
- make check
coverage:
stage: test
.coverage:
script:
- ./autogen && ./configure --disable-static
- make check CFLAGS="--coverage -O0 -ggdb" LDFLAGS="--coverage -O0 -ggdb"
- gcovr -s -e test/
.debian:
image: debian:buster
stage: test
before_script:
- apt-get update -qq
- apt-get install -qq -y --no-install-recommends
git gcc make autoconf automake libtool libmd-dev gcovr
.alpine:
image: alpine:latest
stage: test
before_script:
- apk add --no-cache git gcc make autoconf automake libtool
bsd-compat-headers linux-headers libmd-dev musl-dev gcovr
unit-tests:debian:
extends: [.debian, .unit-tests]
coverage:debian:
extends: [.debian, .coverage]
unit-tests:alpine:
extends: [.alpine, .unit-tests]
coverage:alpine:
extends: [.alpine, .coverage]

View File

@@ -3,7 +3,7 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Files:
*
Copyright:
Copyright © 2004-2006, 2008-2021 Guillem Jover <guillem@hadrons.org>
Copyright © 2004-2006, 2008-2022 Guillem Jover <guillem@hadrons.org>
License: BSD-3-clause
Files:
@@ -364,7 +364,6 @@ Files:
man/strtonum.3bsd
src/arc4random.c
src/arc4random_linux.h
src/arc4random_openbsd.h
src/arc4random_uniform.c
src/arc4random_unix.h
src/arc4random_win.h
@@ -383,6 +382,8 @@ Files:
src/recallocarray.c
src/strlcat.c
src/strlcpy.c
test/explicit_bzero.c
test/strtonum.c
Copyright:
Copyright © 2004 Ted Unangst and Todd Miller
All rights reserved.
@@ -391,6 +392,7 @@ Copyright:
Copyright © 1998, 2000-2002, 2004-2005, 2007, 2010, 2012-2015
Todd C. Miller <Todd.Miller@courtesan.com>
Copyright © 2004 Ted Unangst
Copyright © 2004 Otto Moerbeek <otto@drijf.net>
Copyright © 2008 Damien Miller <djm@openbsd.org>
Copyright © 2008, 2010-2011, 2016-2017 Otto Moerbeek <otto@drijf.net>
Copyright © 2013 Markus Friedl <markus@openbsd.org>
@@ -398,6 +400,7 @@ Copyright:
Copyright © 2014 Brent Cook <bcook@openbsd.org>
Copyright © 2014 Pawel Jakub Dawidek <pjd@FreeBSD.org>
Copyright © 2014 Theo de Raadt <deraadt@openbsd.org>
Copyright © 2014 Google Inc.
Copyright © 2015 Michael Felt <aixtools@gmail.com>
Copyright © 2015 Guillem Jover <guillem@hadrons.org>
License: ISC

32
README
View File

@@ -37,3 +37,35 @@ The master repository can be browsed at:
and cloned from:
<https://anongit.freedesktop.org/git/libbsd>
Building from git source
------------------------
To prepare the libbsd source tree from git before starting the build process
some required software needs to be installed:
GNU autoconf >= 2.67
GNU automake >= 1.9
GNU libtool >= 2.0
After installing the needed software, and running the following command on
the git tree:
$ ./autogen
the source should be roughly equivalent to the distributed tar source.
Building from tar source
------------------------
The minimum software required to configure and build dpkg from a tarball is:
C89 compiler
make
The following software might be required depending on the system:
libmd (whenever the libc does not provide the needed digest functions)
The build process is done by running the usual «./configure; make». To
see all available configuration options please run «./configure --help».

View File

@@ -13,7 +13,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
LIBBSD_ABI_MAJOR=0
LIBBSD_ABI_MINOR=11
LIBBSD_ABI_PATCH=4
LIBBSD_ABI_PATCH=6
LIBBSD_ABI="$LIBBSD_ABI_MAJOR:$LIBBSD_ABI_MINOR:$LIBBSD_ABI_PATCH"
AC_SUBST([LIBBSD_ABI])
@@ -47,6 +47,7 @@ AM_CONDITIONAL([HAVE_LINKER_VERSION_SCRIPT],
[test "x$libbsd_cv_version_script" = "xyes"])
# Checks for programs.
AC_CHECK_TOOL([OBJDUMP], [objdump])
AC_PROG_CC
AC_PROG_SED
AC_PROG_INSTALL

View File

@@ -1,6 +1,6 @@
.\" libbsd man page
.\"
.\" Copyright © 2017-2021 Guillem Jover <guillem@hadrons.org>
.\" Copyright © 2017-2022 Guillem Jover <guillem@hadrons.org>
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@@ -24,7 +24,7 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd Feb 13, 2021
.Dd Mar 30, 2022
.Dt LIBBSD 7
.Os
.Sh NAME
@@ -230,11 +230,15 @@ companion library, so it is advised to switch to use that directly instead.
.It Fn explicit_bzero 3
This function is provided by
.Nm glibc
2.25.
2.25, and
.Nm musl
1.1.20.
.It Fn reallocarray 3
This function is provided by
.Nm glibc
2.26.
2.26, and
.Nm musl
1.2.2.
.El
.Sh SEE ALSO
.Xr arc4random 3bsd ,

View File

@@ -66,7 +66,6 @@ libbsd_la_SOURCES = \
arc4random.c \
arc4random.h \
arc4random_linux.h \
arc4random_openbsd.h \
arc4random_uniform.c \
arc4random_unix.h \
arc4random_win.h \
@@ -141,7 +140,7 @@ TRANSPARENT_LIBMD_DEPENDS = format.ld
format.ld:
$(CC) -shared -nostdlib -nostartfiles -x assembler /dev/null -o $@.so
objdump -f $@.so | sed -n 's/.*file format \(.*\)/OUTPUT_FORMAT(\1)/;T;p' > $@
$(OBJDUMP) -f $@.so | sed -n 's/.*file format \(.*\)/OUTPUT_FORMAT(\1)/;T;p' > $@
rm -f $@.so
endif

View File

@@ -32,9 +32,7 @@
int
getentropy(void *buf, size_t len);
#if defined(__OpenBSD__)
#include "arc4random_openbsd.h"
#elif defined(__linux__)
#if defined(__linux__)
#include "arc4random_linux.h"
#elif defined(_WIN32)
#include "arc4random_win.h"

View File

@@ -1,61 +0,0 @@
/* $OpenBSD: arc4random.h,v 1.3 2014/07/20 20:51:13 bcook Exp $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
* Copyright (c) 2008, Damien Miller <djm@openbsd.org>
* Copyright (c) 2013, Markus Friedl <markus@openbsd.org>
* Copyright (c) 2014, Theo de Raadt <deraadt@openbsd.org>
*
* 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.
*/
/*
* Stub functions for portability.
*/
#include <sys/mman.h>
#include <signal.h>
#include "thread_private.h"
static inline void
_getentropy_fail(void)
{
raise(SIGKILL);
}
static inline int
_rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
{
struct {
struct _rs rs;
struct _rsx rsx;
} *p;
if ((p = mmap(NULL, sizeof(*p), PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED)
return (-1);
if (minherit(p, sizeof(*p), MAP_INHERIT_ZERO) == -1) {
munmap(p, sizeof(*p));
return (-1);
}
*rsp = &p->rs;
*rsxp = &p->rsx;
return (0);
}
static inline void
_rs_forkdetect(void)
{
}

View File

@@ -32,7 +32,7 @@
int
fpurge(FILE *fp)
{
if (fp == NULL || fileno(fp) < 0) {
if (fp == NULL) {
errno = EBADF;
return EOF;
}

View File

@@ -124,6 +124,16 @@
#define ELF_TARG_CLASS ELFCLASS64
#define ELF_TARG_DATA ELFDATA2LSB
#elif defined(__loongarch__)
#define ELF_TARG_MACH EM_LOONGARCH
#if defined(__loongarch64)
#define ELF_TARG_CLASS ELFCLASS64
#else
#error Unsupported ELF class
#endif
#define ELF_TARG_DATA ELFDATA2LSB
#elif defined(__m32r__)
#define ELF_TARG_MACH EM_M32R

6
test/.gitignore vendored
View File

@@ -2,23 +2,25 @@ arc4random
bzero
closefrom
endian
explicit_bzero
fgetln
funopen
fparseln
fpurge
funopen
headers-overlay-gen.c
headers-system-gen.c
humanize
md5
nlist
overlay
proctitle-init
proctitle
proctitle-init
progname
pwcache
setmode
strl
strmode
strnstr
strtonum
vis
vis-openbsd

View File

@@ -34,6 +34,7 @@ check_PROGRAMS = \
bzero \
closefrom \
endian \
explicit_bzero \
humanize \
fgetln \
funopen \
@@ -41,7 +42,6 @@ check_PROGRAMS = \
fpurge \
md5 \
nlist \
proctitle \
proctitle-init \
progname \
pwcache \
@@ -49,6 +49,7 @@ check_PROGRAMS = \
strl \
strmode \
strnstr \
strtonum \
vis \
vis-openbsd \
$(nil)

214
test/explicit_bzero.c Normal file
View File

@@ -0,0 +1,214 @@
/* $OpenBSD: explicit_bzero.c,v 1.7 2021/03/27 11:17:58 bcook Exp $ */
/*
* Copyright (c) 2014 Google Inc.
*
* 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 <assert.h>
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define ASSERT_EQ(a, b) assert((a) == (b))
#define ASSERT_NE(a, b) assert((a) != (b))
#define ASSERT_GE(a, b) assert((a) >= (b))
/* 128 bits of random data. */
static const char secret[16] = {
0xa0, 0x6c, 0x0c, 0x81, 0xba, 0xd8, 0x5b, 0x0c,
0xb0, 0xd6, 0xd4, 0xe3, 0xeb, 0x52, 0x5f, 0x96,
};
enum {
SECRETCOUNT = 64,
SECRETBYTES = SECRETCOUNT * sizeof(secret)
};
/*
* As of glibc 2.34, when _GNU_SOURCE is defined, SIGSTKSZ is no longer
* constant on Linux. SIGSTKSZ is redefined to sysconf (_SC_SIGSTKSZ).
*/
static char *altstack;
#define ALTSTACK_SIZE (SIGSTKSZ + SECRETBYTES)
static void
setup_stack(void)
{
const stack_t sigstk = {
.ss_sp = altstack = calloc(1, ALTSTACK_SIZE),
.ss_size = ALTSTACK_SIZE
};
ASSERT_NE(NULL, altstack);
ASSERT_EQ(0, sigaltstack(&sigstk, NULL));
}
static void
cleanup_stack(void)
{
free(altstack);
}
static void
assert_on_stack(void)
{
stack_t cursigstk;
ASSERT_EQ(0, sigaltstack(NULL, &cursigstk));
ASSERT_EQ(SS_ONSTACK, cursigstk.ss_flags & (SS_DISABLE|SS_ONSTACK));
}
static void
call_on_stack(void (*fn)(int))
{
/*
* This is a bit more complicated than strictly necessary, but
* it ensures we don't have any flaky test failures due to
* inherited signal masks/actions/etc.
*
* On systems where SA_ONSTACK is not supported, this could
* alternatively be implemented using makecontext() or
* pthread_attr_setstack().
*/
const struct sigaction sigact = {
.sa_handler = fn,
.sa_flags = SA_ONSTACK,
};
struct sigaction oldsigact;
sigset_t sigset, oldsigset;
/* First, block all signals. */
ASSERT_EQ(0, sigemptyset(&sigset));
ASSERT_EQ(0, sigfillset(&sigset));
ASSERT_EQ(0, sigprocmask(SIG_BLOCK, &sigset, &oldsigset));
/* Next setup the signal handler for SIGUSR1. */
ASSERT_EQ(0, sigaction(SIGUSR1, &sigact, &oldsigact));
/* Raise SIGUSR1 and momentarily unblock it to run the handler. */
ASSERT_EQ(0, raise(SIGUSR1));
ASSERT_EQ(0, sigdelset(&sigset, SIGUSR1));
ASSERT_EQ(-1, sigsuspend(&sigset));
ASSERT_EQ(EINTR, errno);
/* Restore the original signal action, stack, and mask. */
ASSERT_EQ(0, sigaction(SIGUSR1, &oldsigact, NULL));
ASSERT_EQ(0, sigprocmask(SIG_SETMASK, &oldsigset, NULL));
}
static void
populate_secret(char *buf, ssize_t len)
{
int i, fds[2];
ASSERT_EQ(0, pipe(fds));
for (i = 0; i < SECRETCOUNT; i++)
ASSERT_EQ(sizeof(secret), write(fds[1], secret, sizeof(secret)));
ASSERT_EQ(0, close(fds[1]));
ASSERT_EQ(len, read(fds[0], buf, len));
ASSERT_EQ(0, close(fds[0]));
}
static int
count_secrets(const char *buf)
{
int res = 0;
size_t i;
for (i = 0; i < SECRETCOUNT; i++) {
if (memcmp(buf + i * sizeof(secret), secret,
sizeof(secret)) == 0)
res += 1;
}
return (res);
}
static char *
test_without_bzero(void)
{
char buf[SECRETBYTES];
char *res;
assert_on_stack();
populate_secret(buf, sizeof(buf));
res = memmem(altstack, ALTSTACK_SIZE, buf, sizeof(buf));
ASSERT_NE(NULL, res);
return (res);
}
static char *
test_with_bzero(void)
{
char buf[SECRETBYTES];
char *res;
assert_on_stack();
populate_secret(buf, sizeof(buf));
res = memmem(altstack, ALTSTACK_SIZE, buf, sizeof(buf));
ASSERT_NE(NULL, res);
explicit_bzero(buf, sizeof(buf));
return (res);
}
static void
do_test_without_bzero(int signo)
{
char *buf = test_without_bzero();
ASSERT_GE(count_secrets(buf), 1);
}
static void
do_test_with_bzero(int signo)
{
char *buf = test_with_bzero();
ASSERT_EQ(count_secrets(buf), 0);
}
int
main(int argc, char **argv)
{
setup_stack();
/*
* Solaris and OS X clobber the signal stack after returning to the
* normal stack, so we need to inspect altstack while we're still
* running on it. Unfortunately, this means we risk clobbering the
* buffer ourselves.
*
* To minimize this risk, test_with{,out}_bzero() are responsible for
* locating the offset of their buf variable within altstack, and
* and returning that address. Then we can simply memcmp() repeatedly
* to count how many instances of secret we found.
*/
/*
* First, test that if we *don't* call explicit_bzero, that we
* *are* able to find at least one instance of the secret data still
* on the stack. This sanity checks that call_on_stack() and
* populate_secret() work as intended.
*/
memset(altstack, 0, ALTSTACK_SIZE);
call_on_stack(do_test_without_bzero);
/*
* Now test with a call to explicit_bzero() and check that we
* *don't* find any instances of the secret data.
*/
memset(altstack, 0, ALTSTACK_SIZE);
call_on_stack(do_test_with_bzero);
cleanup_stack();
return (0);
}

View File

@@ -25,24 +25,33 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int
main(int argc, char *argv[])
{
static FILE fp_bad;
FILE *fp;
char *buf = NULL;
size_t bufsz = 0;
if (fpurge(NULL) == 0)
return 1;
if (fpurge(&fp_bad) == 0)
return 1;
fp = fopen("/dev/zero", "r");
if (fpurge(fp) < 0)
return 1;
fclose(fp);
fp = open_memstream(&buf, &bufsz);
fputs("World", fp);
if (fpurge(fp) < 0)
return 1;
fflush(fp);
if (bufsz != 0)
return 1;
free(buf);
return 0;
}

64
test/strtonum.c Normal file
View File

@@ -0,0 +1,64 @@
/* $OpenBSD: strtonumtest.c,v 1.1 2004/08/03 20:38:36 otto Exp $ */
/*
* Copyright (c) 2004 Otto Moerbeek <otto@drijf.net>
*
* 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 <limits.h>
#include <stdio.h>
#include <stdlib.h>
static int fail;
static void
test(const char *p, long long lb, long long ub, int ok)
{
long long val;
const char *q;
val = strtonum(p, lb, ub, &q);
if (ok && q != NULL) {
fprintf(stderr, "%s [%lld-%lld] ", p, lb, ub);
fprintf(stderr, "NUMBER NOT ACCEPTED %s\n", q);
fail = 1;
} else if (!ok && q == NULL) {
fprintf(stderr, "%s [%lld-%lld] %lld ", p, lb, ub, val);
fprintf(stderr, "NUMBER ACCEPTED\n");
fail = 1;
}
}
int main(int argc, char *argv[])
{
test("1", 0, 10, 1);
test("0", -2, 5, 1);
test("0", 2, 5, 0);
test("0", 2, LLONG_MAX, 0);
test("-2", 0, LLONG_MAX, 0);
test("0", -5, LLONG_MAX, 1);
test("-3", -3, LLONG_MAX, 1);
test("-9223372036854775808", LLONG_MIN, LLONG_MAX, 1);
test("9223372036854775807", LLONG_MIN, LLONG_MAX, 1);
test("-9223372036854775809", LLONG_MIN, LLONG_MAX, 0);
test("9223372036854775808", LLONG_MIN, LLONG_MAX, 0);
test("1000000000000000000000000", LLONG_MIN, LLONG_MAX, 0);
test("-1000000000000000000000000", LLONG_MIN, LLONG_MAX, 0);
test("-2", 10, -1, 0);
test("-2", -10, -1, 1);
test("-20", -10, -1, 0);
test("20", -10, -1, 0);
return (fail);
}