Compare commits

...

8 Commits
0.8.2 ... 0.8.3

Author SHA1 Message Date
Guillem Jover
9bed430ee3 Release libbsd 0.8.3 2016-04-23 10:13:23 +02:00
Szabolcs Nagy
cbfe0ebca9 Add missing <fcntl.h> includes
These are required due to the O_* macro usage, but have passed
undetected on glibc-based systems due to implicit inclusions.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2016-03-27 12:42:34 +02:00
Guillem Jover
f3b566bd7c test: Add a unit test for md5 2016-03-27 12:31:58 +02:00
Guillem Jover
e86c1b5f43 man: Fix ungrammatical construct
Warned-by: lintian
2016-02-14 09:01:24 +01:00
Guillem Jover
b7ce33cf51 build: Support clock_gettime() provided in librt
In older glibc versions (< 2.17) clock_gettime() is in librt. Add a
check for this to avoid build breakage for programs/libraries that
use libbsd on such systems.

Based-on-patch-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2016-02-13 08:46:47 +01:00
Guillem Jover
ed84bec5aa Switch URLs from http or git to https 2016-02-13 08:46:35 +01:00
Guillem Jover
cbe3057703 Fix file descriptor leak in HASHFileChunk helper
This leak only happens on error conditions, so it's not too bad.

Warned-by: coverity
2016-02-07 09:17:08 +01:00
Guillem Jover
5a32ea0a72 Fix unportable sizeof() usage
We are calculating the size of the array, and need to pass the size of
each element, not the size of a pointer to an element. Although this
happens to be the same in many cases, this is not a portable assumption.

Warned-by: coverity
2016-02-07 09:16:47 +01:00
17 changed files with 87 additions and 16 deletions

View File

@@ -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:
*

13
README
View File

@@ -9,7 +9,7 @@ code over and over again on each project.
Releases
--------
<http://libbsd.freedesktop.org/releases/>
<https://libbsd.freedesktop.org/releases/>
Mailing List
@@ -17,7 +17,7 @@ Mailing List
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:
@@ -27,5 +27,10 @@ The mail address is:
Source Repository
-----------------
<http://cgit.freedesktop.org/libbsd>
<git://anongit.freedesktop.org/git/libbsd>
The master repository can be browsed at:
<https://cgit.freedesktop.org/libbsd>
and cloned from:
<https://anongit.freedesktop.org/git/libbsd>

View File

@@ -13,7 +13,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
LIBBSD_ABI_MAJOR=0
LIBBSD_ABI_MINOR=8
LIBBSD_ABI_PATCH=2
LIBBSD_ABI_PATCH=3
LIBBSD_ABI="$LIBBSD_ABI_MAJOR:$LIBBSD_ABI_MINOR:$LIBBSD_ABI_PATCH"
AC_SUBST([LIBBSD_ABI])
@@ -44,6 +44,16 @@ AC_SUBST([TESTU01_LIBS])
AM_CONDITIONAL([HAVE_LIBTESTU01],
[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.
AC_CHECK_HEADERS([sys/ndir.h sys/dir.h ndir.h dirent.h])

View File

@@ -1059,7 +1059,7 @@ However, unlike their unsafe counterparts,
.Nm TAILQ_FOREACH
and
.Nm TAILQ_FOREACH_REVERSE
permit to both remove
make it possible to both remove
.Fa var
as well as free it from within the loop safely without interfering with the
traversal.

View File

@@ -52,6 +52,8 @@ hash/md5hl.c: $(srcdir)/hash/helper.c
libbsd_la_DEPENDENCIES = \
$(libbsd_la_included_sources) \
libbsd.map
libbsd_la_LIBADD = \
$(CLOCK_GETTIME_LIBS)
libbsd_la_LDFLAGS = \
-Wl,--version-script=$(srcdir)/libbsd.map \
-version-number $(LIBBSD_ABI)

View File

@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <unistd.h>
#include <libutil.h>

View File

@@ -67,8 +67,10 @@ HASHFileChunk(const char *filename, char *buf, off_t off, off_t len)
}
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);
}
while ((nr = read(fd, buffer,
(size_t)(len ? MIN(BUFSIZ, len) : BUFSIZ))) > 0) {

View File

@@ -6,7 +6,7 @@ includedir=@includedir@
Name: libbsd-ctor
Description: Automatic constructor functions for libbsd
Version: @VERSION@
URL: http://libbsd.freedesktop.org/
URL: https://libbsd.freedesktop.org/
Cflags: -I${includedir}
Libs: -L${libdir} -Wl,-z,nodlopen -Wl,-u,libbsd_init_func -lbsd-ctor
Requires: libbsd

View File

@@ -6,6 +6,6 @@ includedir=@includedir@
Name: libbsd
Description: Utility functions from BSD systems (overlay)
Version: @VERSION@
URL: http://libbsd.freedesktop.org/
URL: https://libbsd.freedesktop.org/
Libs: -L${libdir} -lbsd
Cflags: -isystem ${includedir}/bsd -DLIBBSD_OVERLAY

View File

@@ -6,6 +6,6 @@ includedir=@includedir@
Name: libbsd
Description: Utility functions from BSD systems
Version: @VERSION@
URL: http://libbsd.freedesktop.org/
URL: https://libbsd.freedesktop.org/
Libs: -L${libdir} -lbsd
Cflags: -I${includedir}

View File

@@ -39,6 +39,7 @@ static char sccsid[] = "@(#)nlist.c 8.1 (Berkeley) 6/4/93";
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <a.out.h>
#include <stdio.h>
#include <string.h>

View File

@@ -25,9 +25,10 @@
* 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 <string.h>

View File

@@ -118,7 +118,7 @@ sradixsort(const u_char **a, int n, const u_char *tab, u_int endch)
if (n < THRESHOLD)
simplesort(a, n, 0, tr, endch);
else {
ta = reallocarray(NULL, n, sizeof(a));
ta = reallocarray(NULL, n, sizeof(*a));
if (ta == NULL)
return (-1);
r_sort_b(a, ta, n, 0, tr, endch);

View File

@@ -56,7 +56,7 @@ spt_min(size_t a, size_t b)
/*
* 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
spt_clearenv(void)

1
test/.gitignore vendored
View File

@@ -8,6 +8,7 @@ fparseln
fpurge
headers-gen.c
humanize
md5
overlay
proctitle-init
proctitle

View File

@@ -39,6 +39,7 @@ check_PROGRAMS = \
funopen \
fparseln \
fpurge \
md5 \
proctitle-init \
strmode \
$(nil)

47
test/md5.c Normal file
View 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;
}