Compare commits

..

10 Commits
0.8.4 ... 0.8.6

Author SHA1 Message Date
Guillem Jover
bbf90ac3cd Release libbsd 0.8.6 2017-07-17 01:01:13 +02:00
Guillem Jover
2a8514d8a5 Fix handling of non-contiguous argv + envp in setproctitle()
The two arrays might not reference contiguous memory, and assuming they
are does break at least now on GNU/Hurd, which contains an unmapped
memory block between the memory used by the two arrays.

Just check that each element is strictly after the previous one, so that
we know there are no unmapped memory blocks inbetween.
2017-07-17 00:58:06 +02:00
Guillem Jover
3b2b7938f7 test: Fix nlist() unit test on IA64 and PowerPC 64-bit ELFv1
At least on IA64 and PowerPC 64-bit ELFv1, the functions are stored in
the .text sections but they are accessed through a function descriptor
stored in a data section, for example for PowerPC 64-bit ELFv1 that
section is called .opd.

We should take this into account when checking the n_type for the
functions we have requested information from nlist().

Rationale-by: James Clarke <jrtc27@jrtc27.com>
2017-06-25 02:10:26 +02:00
Guillem Jover
415e3cb266 Release libbsd 0.8.5 2017-06-24 16:10:14 +02:00
Guillem Jover
9532cb39f4 man: Update man page sections in titles and references
We have moved all man pages to section 3bsd, let's do the same for the
page title, and in all the references for uniformity and to avoid
confusions.

Fixes: https://bugs.freedesktop.org/101545
2017-06-24 16:08:27 +02:00
Guillem Jover
a4dd754c8d man: Ship and install libbsd(7)
Fixes: https://bugs.freedesktop.org/101543
2017-06-24 16:08:27 +02:00
James Cowgill
b480b7a3f8 Fix ELF definitions for MIPS in local-elf.h
Add a check for _MIPS_SIM inside the __mips__ #elif to detect mips64el
and use ELFCLASS64 in that case. Note that we can't use defined(__mips64)
here because that is also defined when the n32 ABI is in use, which uses
ELFCLASS32.

Fixes: https://bugs.debian.org/865091
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2017-06-24 16:08:22 +02:00
James Cowgill
4cc20e23f5 Fix ELF definitions for PowerPC in local-elf.h
* ppc64el defines both __powerpc__ and __powerpc64__ but since the
  __powerpc64__ #elif is below the __powerpc__ one, it will never be hit.
* Both assumed that powerpc* was big-endian.

Fixes: https://bugs.debian.org/865091
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2017-06-24 16:08:14 +02:00
Guillem Jover
c4e58c0950 test: Remove unused variable in nlist() unit test 2017-06-24 16:06:15 +02:00
Guillem Jover
736e12e8d8 test: Handle libtool executable names in getprogname() unit test
Sometimes libtool will prefix the test programs with "lt-", we should
handle these and strip the prefix.

Fixes: https://bugs.debian.org/865090
2017-06-24 16:05:50 +02:00
45 changed files with 85 additions and 54 deletions

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=4
LIBBSD_ABI_PATCH=6
LIBBSD_ABI="$LIBBSD_ABI_MAJOR:$LIBBSD_ABI_MINOR:$LIBBSD_ABI_PATCH"
AC_SUBST([LIBBSD_ABI])

View File

@@ -181,6 +181,7 @@ dist_man_MANS = \
le32enc.3bsd \
le64dec.3bsd \
le64enc.3bsd \
libbsd.7 \
md5.3bsd \
mergesort.3bsd \
nlist.3bsd \

View File

@@ -31,7 +31,7 @@
.\" Manual page, using -mandoc macros
.\"
.Dd $Mdocdate: July 19 2014 $
.Dt ARC4RANDOM 3
.Dt ARC4RANDOM 3bsd
.Os
.Sh NAME
.Nm arc4random ,

View File

@@ -31,7 +31,7 @@
.\" $FreeBSD$
.\"
.Dd July 19, 1993
.Dt BITSTRING 3
.Dt BITSTRING 3bsd
.Os
.Sh NAME
.Nm bit_alloc ,

View File

@@ -25,7 +25,7 @@
.\" $FreeBSD$
.\"
.Dd April 29, 2002
.Dt BYTEORDER 3
.Dt BYTEORDER 3bsd
.Os
.Sh NAME
.Nm be16enc , be16dec , be32enc , be32dec , be64enc , be64dec ,

View File

@@ -26,7 +26,7 @@
.\" $FreeBSD$
.\"
.Dd June 12, 2009
.Dt CLOSEFROM 3
.Dt CLOSEFROM 3bsd
.Os
.Sh NAME
.Nm closefrom

View File

@@ -28,7 +28,7 @@
.\" SUCH DAMAGE.
.\"
.Dd $Mdocdate: April 23 2014 $
.Dt ERRC 3
.Dt ERRC 3bsd
.Os
.Sh NAME
.Nm errc ,

View File

@@ -26,7 +26,7 @@
.\" $FreeBSD$
.\"
.Dd August 15, 2010
.Dt EXPAND_NUMBER 3
.Dt EXPAND_NUMBER 3bsd
.Os
.Sh NAME
.Nm expand_number

View File

@@ -30,7 +30,7 @@
.\" $OpenBSD: bzero.3,v 1.10 2014/01/22 21:06:45 tedu Exp $
.\"
.Dd $Mdocdate: January 22 2014 $
.Dt BZERO 3
.Dt EXPLICIT_BZERO 3bsd
.Os
.Sh NAME
.Nm explicit_bzero

View File

@@ -29,7 +29,7 @@
.\" $FreeBSD: /repoman/r/ncvs/src/lib/libc/stdio/fgetln.3,v 1.8 2004/07/16 06:07:12 tjr Exp $
.\"
.Dd April 19, 1994
.Dt FGETLN 3
.Dt FGETLN 3bsd
.Os
.Sh NAME
.Nm fgetln

View File

@@ -29,7 +29,7 @@
.\" $FreeBSD$
.\"
.Dd July 16, 2004
.Dt FGETWLN 3
.Dt FGETWLN 3bsd
.Os
.Sh NAME
.Nm fgetwln

View File

@@ -26,7 +26,7 @@
.\" $FreeBSD$
.\"
.Dd June 6, 2009
.Dt FLOPEN 3
.Dt FLOPEN 3bsd
.Os
.Sh NAME
.Nm flopen

View File

@@ -27,7 +27,7 @@
.\" $FreeBSD: /repoman/r/ncvs/src/lib/libc/gen/fmtcheck.3,v 1.9 2004/07/02 23:52:10 ru Exp $
.Dd October 16, 2002
.Os
.Dt FMTCHECK 3
.Dt FMTCHECK 3bsd
.Sh NAME
.Nm fmtcheck
.Nd sanitizes user-supplied

View File

@@ -23,7 +23,7 @@
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd November 30, 2002
.Dt FPARSELN 3
.Dt FPARSELN 3bsd
.Os
.Sh NAME
.Nm fparseln

View File

@@ -32,7 +32,7 @@
.\" SUCH DAMAGE.
.\"
.Dd $Mdocdate: November 4 2015 $
.Dt FPURGE 3
.Dt FPURGE 3bsd
.Os
.Sh NAME
.Nm fpurge

View File

@@ -31,7 +31,7 @@
.\" $FreeBSD$
.\"
.Dd March 19, 2004
.Dt FUNOPEN 3
.Dt FUNOPEN 3bsd
.Os
.Sh NAME
.Nm funopen ,

View File

@@ -29,7 +29,7 @@
.\" $FreeBSD$
.\"
.Dd November 16, 2012
.Dt GETBSIZE 3
.Dt GETBSIZE 3bsd
.Os
.Sh NAME
.Nm getbsize

View File

@@ -26,7 +26,7 @@
.\" $FreeBSD$
.\"
.Dd July 15, 2001
.Dt GETPEEREID 3
.Dt GETPEEREID 3bsd
.Os
.Sh NAME
.Nm getpeereid

View File

@@ -32,7 +32,7 @@
.\" $FreeBSD$
.\"
.Dd May 1, 2001
.Dt GETPROGNAME 3
.Dt GETPROGNAME 3bsd
.Os
.Sh NAME
.Nm getprogname ,

View File

@@ -33,7 +33,7 @@
.\" $FreeBSD$
.\"
.Dd September 30, 2003
.Dt QSORT 3
.Dt HEAPSORT 3bsd
.Os
.Sh NAME
.Nm heapsort , mergesort

View File

@@ -28,7 +28,7 @@
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd February 9, 2008
.Dt HUMANIZE_NUMBER 3
.Dt HUMANIZE_NUMBER 3bsd
.Os
.Sh NAME
.Nm dehumanize_number ,

View File

@@ -29,7 +29,7 @@
.\" $FreeBSD: /repoman/r/ncvs/src/lib/libc/gen/nlist.3,v 1.7 2001/10/01 16:08:51 ru Exp $
.\"
.Dd April 19, 1994
.Dt NLIST 3
.Dt NLIST 3bsd
.Os
.Sh NAME
.Nm nlist

View File

@@ -25,7 +25,7 @@
.\" $FreeBSD$
.\"
.Dd October 20, 2008
.Dt PIDFILE 3
.Dt PIDFILE 3bsd
.Os
.Sh NAME
.Nm pidfile_open ,

View File

@@ -29,7 +29,7 @@
.\" $FreeBSD$
.\"
.Dd June 17, 2013
.Dt QUEUE 3
.Dt QUEUE 3bsd
.Os
.Sh NAME
.Nm SLIST_EMPTY ,

View File

@@ -30,7 +30,7 @@
.\" from: @(#)radixsort.3 8.2 (Berkeley) 1/27/94
.\"
.Dd January 27, 1994
.Dt RADIXSORT 3
.Dt RADIXSORT 3bsd
.Os
.Sh NAME
.Nm radixsort ,

View File

@@ -19,7 +19,7 @@
.\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
.\"
.Dd $Mdocdate: May 31 2007 $
.Dt READPASSPHRASE 3
.Dt READPASSPHRASE 3bsd
.Os
.Sh NAME
.Nm readpassphrase

View File

@@ -33,7 +33,7 @@
.\" $OpenBSD: malloc.3,v 1.78 2014/05/01 18:41:59 jmc Exp $
.\"
.Dd $Mdocdate: May 1 2014 $
.Dt MALLOC 3
.Dt REALLOCARRAY 3bsd
.Os
.Sh NAME
.Nm reallocarray

View File

@@ -33,7 +33,7 @@
.\" $FreeBSD: src/lib/libc/stdlib/malloc.3,v 1.80.2.2.2.1 2010/06/14 02:09:06 kensmith Exp $
.\"
.Dd September 26, 2009
.Dt MALLOC 3
.Dt REALLOCF 3bsd
.Os
.Sh NAME
.Nm reallocf

View File

@@ -31,7 +31,7 @@
.\" $FreeBSD: src/lib/libc/gen/setmode.3,v 1.12 2007/01/09 00:27:55 imp Exp $
.\"
.Dd January 4, 2009
.Dt SETMODE 3
.Dt SETMODE 3bsd
.Os
.Sh NAME
.Nm getmode ,

View File

@@ -21,7 +21,7 @@
.\"
.\" The following requests are required for all man pages.
.Dd December 16, 1995
.Dt SETPROCTITLE 3
.Dt SETPROCTITLE 3bsd
.Os
.Sh NAME
.Nm setproctitle

View File

@@ -27,7 +27,7 @@
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd May 6, 2010
.Dt STRINGLIST 3
.Dt STRINGLIST 3bsd
.Os
.Sh NAME
.Nm stringlist ,

View File

@@ -15,7 +15,7 @@
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: May 31 2007 $
.Dt STRLCPY 3
.Dt STRLCPY 3bsd
.Os
.Sh NAME
.Nm strlcpy ,

View File

@@ -29,7 +29,7 @@
.\" $FreeBSD: src/lib/libc/string/strmode.3,v 1.9 2003/07/01 15:28:05 maxim Exp $
.\"
.Dd July 28, 1994
.Dt STRMODE 3
.Dt STRMODE 3bsd
.Os
.Sh NAME
.Nm strmode

View File

@@ -34,7 +34,7 @@
.\" $FreeBSD$
.\"
.Dd October 11, 2001
.Dt STRSTR 3
.Dt STRSTR 3bsd
.Os
.Sh NAME
.Nm strnstr

View File

@@ -16,7 +16,7 @@
.\" $FreeBSD$
.\"
.Dd April 29, 2004
.Dt STRTONUM 3
.Dt STRTONUM 3bsd
.Os
.Sh NAME
.Nm strtonum

View File

@@ -31,7 +31,7 @@
.\" $FreeBSD: src/share/man/man3/timeradd.3,v 1.3 2003/09/08 19:57:19 ru Exp $
.\"
.Dd June 7, 2010
.Dt TIMERADD 3
.Dt TIMERADD 3bsd
.Os
.Sh NAME
.Nm timeradd ,
@@ -81,7 +81,7 @@ These macros are provided for manipulating the
and
.Fa timespec
structures described in
.Xr timeval 3 .
.Xr timeval 3bsd .
.Pp
The
.Fn timeradd
@@ -145,7 +145,7 @@ using the comparison operator given in
.Fa CMP .
The result of the comparison is returned.
.Sh SEE ALSO
.Xr timeval 3
.Xr timeval 3bsd
.Sh HISTORY
The
.Fn timeradd

View File

@@ -28,7 +28,7 @@
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd April 12, 2011
.Dt TIMEVAL 3
.Dt TIMEVAL 3bsd
.Os
.Sh NAME
.Nm timeval ,
@@ -130,4 +130,4 @@ example(struct timespec *spec, time_t minutes)
A better alternative would use the more precise
.Xr clock_gettime 2 .
.Sh SEE ALSO
.Xr timeradd 3
.Xr timeradd 3bsd

View File

@@ -31,7 +31,7 @@
.\" $FreeBSD$
.\"
.Dd December 27, 2007
.Dt TREE 3
.Dt TREE 3bsd
.Os
.Sh NAME
.Nm SPLAY_PROTOTYPE ,

View File

@@ -28,7 +28,7 @@
.\" SUCH DAMAGE.
.\"
.Dd $Mdocdate: May 31 2007 $
.Dt UNVIS 3
.Dt UNVIS 3bsd
.Os
.Sh NAME
.Nm unvis ,

View File

@@ -28,7 +28,7 @@
.\" SUCH DAMAGE.
.\"
.Dd $Mdocdate: May 31 2007 $
.Dt VIS 3
.Dt VIS 3bsd
.Os
.Sh NAME
.Nm vis ,
@@ -144,7 +144,7 @@ returns the length that
would become if it were of unlimited size (similar to
.Xr snprintf 3
or
.Xr strlcpy 3 ) .
.Xr strlcpy 3bsd ) .
This can be used to detect truncation but it also means that
the return value of
.Fn strnvis

View File

@@ -36,7 +36,7 @@
.\" $FreeBSD$
.\"
.Dd March 4, 2009
.Dt WCSLCPY 3
.Dt WCSLCPY 3bsd
.Os
.Sh NAME
.Nm wcslcat ,

View File

@@ -127,7 +127,11 @@
#elif defined(__mips__)
#define ELF_TARG_MACH EM_MIPS
#if defined(_ABI64) && _MIPS_SIM == _ABI64
#define ELF_TARG_CLASS ELFCLASS64
#else
#define ELF_TARG_CLASS ELFCLASS32
#endif
#if defined(__MIPSEB__)
#define ELF_TARG_DATA ELFDATA2MSB
#else
@@ -140,17 +144,29 @@
#define ELF_TARG_CLASS ELFCLASS32
#define ELF_TARG_DATA ELFDATA2LSB
#elif defined(__powerpc__)
#define ELF_TARG_MACH EM_PPC
#define ELF_TARG_CLASS ELFCLASS32
#define ELF_TARG_DATA ELFDATA2MSB
#elif defined(__powerpc64__)
#define ELF_TARG_MACH EM_PPC64
#define ELF_TARG_CLASS ELFCLASS64
#if defined(__LITTLE_ENDIAN__)
#define ELF_TARG_DATA ELFDATA2LSB
#elif defined(__BIG_ENDIAN__)
#define ELF_TARG_DATA ELFDATA2MSB
#else
#error Unknown PowerPC64 endianness
#endif
#elif defined(__powerpc__)
#define ELF_TARG_MACH EM_PPC
#define ELF_TARG_CLASS ELFCLASS32
#if defined(__LITTLE_ENDIAN__)
#define ELF_TARG_DATA ELFDATA2LSB
#elif defined(__BIG_ENDIAN__)
#define ELF_TARG_DATA ELFDATA2MSB
#else
#error Unknown PowerPC endianness
#endif
#elif defined(__riscv)

View File

@@ -173,14 +173,14 @@ setproctitle_init(int argc, char *argv[], char *envp[])
end = nul + 1;
for (i = 0; i < argc || (i >= argc && argv[i]); i++) {
if (argv[i] == NULL || argv[i] < end)
if (argv[i] == NULL || argv[i] != end)
continue;
end = argv[i] + strlen(argv[i]) + 1;
}
for (i = 0; envp[i]; i++) {
if (envp[i] < end)
if (envp[i] != end)
continue;
end = envp[i] + strlen(envp[i]) + 1;

View File

@@ -61,7 +61,7 @@ main(int argc, char **argv)
{ .n_un.n_name = "data_pub_init" },
{ .n_un.n_name = "data_prv_init" },
{ .n_un.n_name = NULL },
}, *nlp;
};
int rc;
assert(*data_pub_ptr == 50);
@@ -69,8 +69,17 @@ main(int argc, char **argv)
rc = nlist(argv[0], nl);
assert(rc == 0);
#if defined(__ia64__) || (defined(__powerpc64__) && _CALL_ELF == 1)
/* On IA64 and PowerPC 64-bit ELFv1, the functions are stored in
* the .text sections but they are accessed through a function
* descriptor stored in a data section, for example for PowerPC
* 64-bit that section is called .opd. */
assert(nl[0].n_type == (N_DATA | N_EXT));
assert(nl[1].n_type == (N_DATA | N_EXT));
#else
assert(nl[0].n_type == (N_TEXT | N_EXT));
assert(nl[1].n_type == (N_TEXT | N_EXT));
#endif
assert(nl[2].n_type == (N_BSS | N_EXT));
assert(nl[3].n_type == (N_DATA | N_EXT));
assert(nl[4].n_type == (N_DATA));

View File

@@ -31,7 +31,12 @@
int
main(int argc, char **argv)
{
assert(strcmp(getprogname(), "progname") == 0);
const char *progname;
progname = getprogname();
if (strncmp(progname, "lt-", 3) == 0)
progname += 3;
assert(strcmp(progname, "progname") == 0);
setprogname("program-name");
assert(strcmp(getprogname(), "program-name") == 0);