mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-10-19 21:16:55 +02:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9bed430ee3 | ||
![]() |
cbfe0ebca9 | ||
![]() |
f3b566bd7c | ||
![]() |
e86c1b5f43 | ||
![]() |
b7ce33cf51 | ||
![]() |
ed84bec5aa | ||
![]() |
cbe3057703 | ||
![]() |
5a32ea0a72 |
2
COPYING
2
COPYING
@@ -1,4 +1,4 @@
|
|||||||
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||||
|
|
||||||
Files:
|
Files:
|
||||||
*
|
*
|
||||||
|
13
README
13
README
@@ -9,7 +9,7 @@ code over and over again on each project.
|
|||||||
Releases
|
Releases
|
||||||
--------
|
--------
|
||||||
|
|
||||||
<http://libbsd.freedesktop.org/releases/>
|
<https://libbsd.freedesktop.org/releases/>
|
||||||
|
|
||||||
|
|
||||||
Mailing List
|
Mailing List
|
||||||
@@ -17,7 +17,7 @@ Mailing List
|
|||||||
|
|
||||||
The subscription interface and web archives can be found at:
|
The subscription interface and web archives can be found at:
|
||||||
|
|
||||||
<http://lists.freedesktop.org/mailman/listinfo/libbsd>
|
<https://lists.freedesktop.org/mailman/listinfo/libbsd>
|
||||||
|
|
||||||
The mail address is:
|
The mail address is:
|
||||||
|
|
||||||
@@ -27,5 +27,10 @@ The mail address is:
|
|||||||
Source Repository
|
Source Repository
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
<http://cgit.freedesktop.org/libbsd>
|
The master repository can be browsed at:
|
||||||
<git://anongit.freedesktop.org/git/libbsd>
|
|
||||||
|
<https://cgit.freedesktop.org/libbsd>
|
||||||
|
|
||||||
|
and cloned from:
|
||||||
|
|
||||||
|
<https://anongit.freedesktop.org/git/libbsd>
|
||||||
|
12
configure.ac
12
configure.ac
@@ -13,7 +13,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
|
|||||||
|
|
||||||
LIBBSD_ABI_MAJOR=0
|
LIBBSD_ABI_MAJOR=0
|
||||||
LIBBSD_ABI_MINOR=8
|
LIBBSD_ABI_MINOR=8
|
||||||
LIBBSD_ABI_PATCH=2
|
LIBBSD_ABI_PATCH=3
|
||||||
|
|
||||||
LIBBSD_ABI="$LIBBSD_ABI_MAJOR:$LIBBSD_ABI_MINOR:$LIBBSD_ABI_PATCH"
|
LIBBSD_ABI="$LIBBSD_ABI_MAJOR:$LIBBSD_ABI_MINOR:$LIBBSD_ABI_PATCH"
|
||||||
AC_SUBST([LIBBSD_ABI])
|
AC_SUBST([LIBBSD_ABI])
|
||||||
@@ -44,6 +44,16 @@ AC_SUBST([TESTU01_LIBS])
|
|||||||
AM_CONDITIONAL([HAVE_LIBTESTU01],
|
AM_CONDITIONAL([HAVE_LIBTESTU01],
|
||||||
[test "x$ac_cv_lib_testu01_unif01_CreateExternGenBits" = "xyes"])
|
[test "x$ac_cv_lib_testu01_unif01_CreateExternGenBits" = "xyes"])
|
||||||
|
|
||||||
|
# In old glibc versions (< 2.17) clock_gettime() is in librt.
|
||||||
|
AS_CASE([$host_os],
|
||||||
|
[*-gnu], [
|
||||||
|
saved_LIBS="$LIBS"
|
||||||
|
AC_SEARCH_LIBS([clock_gettime], [rt], [CLOCK_GETTIME_LIBS="-lrt"])
|
||||||
|
AC_SUBST([CLOCK_GETTIME_LIBS])
|
||||||
|
LIBS="$saved_LIBS"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
# Checks for header files.
|
# Checks for header files.
|
||||||
AC_CHECK_HEADERS([sys/ndir.h sys/dir.h ndir.h dirent.h])
|
AC_CHECK_HEADERS([sys/ndir.h sys/dir.h ndir.h dirent.h])
|
||||||
|
|
||||||
|
@@ -1059,7 +1059,7 @@ However, unlike their unsafe counterparts,
|
|||||||
.Nm TAILQ_FOREACH
|
.Nm TAILQ_FOREACH
|
||||||
and
|
and
|
||||||
.Nm TAILQ_FOREACH_REVERSE
|
.Nm TAILQ_FOREACH_REVERSE
|
||||||
permit to both remove
|
make it possible to both remove
|
||||||
.Fa var
|
.Fa var
|
||||||
as well as free it from within the loop safely without interfering with the
|
as well as free it from within the loop safely without interfering with the
|
||||||
traversal.
|
traversal.
|
||||||
|
@@ -52,6 +52,8 @@ hash/md5hl.c: $(srcdir)/hash/helper.c
|
|||||||
libbsd_la_DEPENDENCIES = \
|
libbsd_la_DEPENDENCIES = \
|
||||||
$(libbsd_la_included_sources) \
|
$(libbsd_la_included_sources) \
|
||||||
libbsd.map
|
libbsd.map
|
||||||
|
libbsd_la_LIBADD = \
|
||||||
|
$(CLOCK_GETTIME_LIBS)
|
||||||
libbsd_la_LDFLAGS = \
|
libbsd_la_LDFLAGS = \
|
||||||
-Wl,--version-script=$(srcdir)/libbsd.map \
|
-Wl,--version-script=$(srcdir)/libbsd.map \
|
||||||
-version-number $(LIBBSD_ABI)
|
-version-number $(LIBBSD_ABI)
|
||||||
|
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <libutil.h>
|
#include <libutil.h>
|
||||||
|
@@ -67,8 +67,10 @@ HASHFileChunk(const char *filename, char *buf, off_t off, off_t len)
|
|||||||
}
|
}
|
||||||
len = sb.st_size;
|
len = sb.st_size;
|
||||||
}
|
}
|
||||||
if ((len < 0) || (off > 0 && lseek(fd, off, SEEK_SET) < 0))
|
if ((len < 0) || (off > 0 && lseek(fd, off, SEEK_SET) < 0)) {
|
||||||
|
close(fd);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
while ((nr = read(fd, buffer,
|
while ((nr = read(fd, buffer,
|
||||||
(size_t)(len ? MIN(BUFSIZ, len) : BUFSIZ))) > 0) {
|
(size_t)(len ? MIN(BUFSIZ, len) : BUFSIZ))) > 0) {
|
||||||
|
@@ -6,7 +6,7 @@ includedir=@includedir@
|
|||||||
Name: libbsd-ctor
|
Name: libbsd-ctor
|
||||||
Description: Automatic constructor functions for libbsd
|
Description: Automatic constructor functions for libbsd
|
||||||
Version: @VERSION@
|
Version: @VERSION@
|
||||||
URL: http://libbsd.freedesktop.org/
|
URL: https://libbsd.freedesktop.org/
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
Libs: -L${libdir} -Wl,-z,nodlopen -Wl,-u,libbsd_init_func -lbsd-ctor
|
Libs: -L${libdir} -Wl,-z,nodlopen -Wl,-u,libbsd_init_func -lbsd-ctor
|
||||||
Requires: libbsd
|
Requires: libbsd
|
||||||
|
@@ -6,6 +6,6 @@ includedir=@includedir@
|
|||||||
Name: libbsd
|
Name: libbsd
|
||||||
Description: Utility functions from BSD systems (overlay)
|
Description: Utility functions from BSD systems (overlay)
|
||||||
Version: @VERSION@
|
Version: @VERSION@
|
||||||
URL: http://libbsd.freedesktop.org/
|
URL: https://libbsd.freedesktop.org/
|
||||||
Libs: -L${libdir} -lbsd
|
Libs: -L${libdir} -lbsd
|
||||||
Cflags: -isystem ${includedir}/bsd -DLIBBSD_OVERLAY
|
Cflags: -isystem ${includedir}/bsd -DLIBBSD_OVERLAY
|
||||||
|
@@ -6,6 +6,6 @@ includedir=@includedir@
|
|||||||
Name: libbsd
|
Name: libbsd
|
||||||
Description: Utility functions from BSD systems
|
Description: Utility functions from BSD systems
|
||||||
Version: @VERSION@
|
Version: @VERSION@
|
||||||
URL: http://libbsd.freedesktop.org/
|
URL: https://libbsd.freedesktop.org/
|
||||||
Libs: -L${libdir} -lbsd
|
Libs: -L${libdir} -lbsd
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
@@ -39,6 +39,7 @@ static char sccsid[] = "@(#)nlist.c 8.1 (Berkeley) 6/4/93";
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <a.out.h>
|
#include <a.out.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@@ -25,9 +25,10 @@
|
|||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Rejected in glibc (http://sourceware.org/ml/libc-alpha/2006-03/msg00125.html)
|
* Rejected in glibc
|
||||||
*/
|
* <https://sourceware.org/ml/libc-alpha/2006-03/msg00125.html>.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@@ -118,7 +118,7 @@ sradixsort(const u_char **a, int n, const u_char *tab, u_int endch)
|
|||||||
if (n < THRESHOLD)
|
if (n < THRESHOLD)
|
||||||
simplesort(a, n, 0, tr, endch);
|
simplesort(a, n, 0, tr, endch);
|
||||||
else {
|
else {
|
||||||
ta = reallocarray(NULL, n, sizeof(a));
|
ta = reallocarray(NULL, n, sizeof(*a));
|
||||||
if (ta == NULL)
|
if (ta == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
r_sort_b(a, ta, n, 0, tr, endch);
|
r_sort_b(a, ta, n, 0, tr, endch);
|
||||||
|
@@ -56,7 +56,7 @@ spt_min(size_t a, size_t b)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* For discussion on the portability of the various methods, see
|
* For discussion on the portability of the various methods, see
|
||||||
* http://lists.freebsd.org/pipermail/freebsd-stable/2008-June/043136.html
|
* https://lists.freebsd.org/pipermail/freebsd-stable/2008-June/043136.html
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
spt_clearenv(void)
|
spt_clearenv(void)
|
||||||
|
1
test/.gitignore
vendored
1
test/.gitignore
vendored
@@ -8,6 +8,7 @@ fparseln
|
|||||||
fpurge
|
fpurge
|
||||||
headers-gen.c
|
headers-gen.c
|
||||||
humanize
|
humanize
|
||||||
|
md5
|
||||||
overlay
|
overlay
|
||||||
proctitle-init
|
proctitle-init
|
||||||
proctitle
|
proctitle
|
||||||
|
@@ -39,6 +39,7 @@ check_PROGRAMS = \
|
|||||||
funopen \
|
funopen \
|
||||||
fparseln \
|
fparseln \
|
||||||
fpurge \
|
fpurge \
|
||||||
|
md5 \
|
||||||
proctitle-init \
|
proctitle-init \
|
||||||
strmode \
|
strmode \
|
||||||
$(nil)
|
$(nil)
|
||||||
|
47
test/md5.c
Normal file
47
test/md5.c
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright © 2016 Guillem Jover <guillem@hadrons.org>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||||
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <md5.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
test_md5(const char *digest, const char *string)
|
||||||
|
{
|
||||||
|
char result[MD5_DIGEST_STRING_LENGTH];
|
||||||
|
|
||||||
|
assert(strcmp(digest, MD5Data((uint8_t *)string, strlen(string), result)) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
test_md5("d41d8cd98f00b204e9800998ecf8427e", "");
|
||||||
|
test_md5("900150983cd24fb0d6963f7d28e17f72", "abc");
|
||||||
|
test_md5("827ccb0eea8a706c4c34a16891f84e7b", "12345");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Reference in New Issue
Block a user