OSDN Git Service
Rich Felker [Sun, 12 Jan 2014 00:37:09 +0000 (19:37 -0500)]
remove gratuitous temp vars, casts, and suffixes in x86_64 atomic.h
aside from general cleanup, this should allow the identical atomic.h
file to be used for the upcoming x32 port.
Rich Felker [Sat, 11 Jan 2014 16:23:10 +0000 (11:23 -0500)]
remove size suffix in x86_64 __pthread_self asm
the operand size is unnecessary, since the assembler knows it from the
destination register size. removing the suffix makes it so the same
code should work for x32.
Rich Felker [Sat, 11 Jan 2014 16:20:01 +0000 (11:20 -0500)]
make type of st_dev explicitly dev_t in x86_64 stat.h
otherwise it's unclear that it's correct. aside from that, it makes
for a gratuitous difference between the x86_64 header and the upcoming
x32 header.
Rich Felker [Thu, 9 Jan 2014 00:39:18 +0000 (19:39 -0500)]
fix namespace violation in sys/shm.h
in fixing this, I've changed the logic from ugly #if/#else blocks
inside the struct shm_info definition to a fixed struct definition and
optional macros to rename the elements. this will be helpful if we
need to move shm_info to a bits header in the future, as it will keep
the feature test logic out of bits.
Rich Felker [Thu, 9 Jan 2014 00:36:29 +0000 (19:36 -0500)]
fix namespace violations in utmpx.h
Rich Felker [Thu, 9 Jan 2014 00:27:56 +0000 (19:27 -0500)]
add IUTF8 to termios.h on archs that were missing it
Rich Felker [Thu, 9 Jan 2014 00:20:55 +0000 (19:20 -0500)]
fix namespace violations in termios.h, at least mostly
the fix should be complete on archs that use the generic definitions
(i386, arm, x86_64, microblaze), but mips and powerpc have not been
checked thoroughly and may need more fixes.
Rich Felker [Wed, 8 Jan 2014 23:54:33 +0000 (18:54 -0500)]
fix remaining known namespace violations for netinet/in.h
the imr_, imsf_, ip6_, ip6m_, ipi_, ipi6_, SCM_, and SOL_ prefixes are
not in the reserved namespace for this header. thus the constants and
structures using them need to be protected under appropriate feature
test macros.
this also affects some headers which are permitted to include
netinet/in.h, particularly netdb.h and arpa/inet.h.
the SOL_ macros are moved to sys/socket.h where they are in the
reserved namespace (SO*). they are still accessible via netinet/in.h
since it includes sys/socket.h implicitly (which is permitted).
the SCM_SRCRT macro is simply removed, since the definition used for
it, IPV6_RXSRCRT is not defined anywhere. it could be re-added, this
time in sys/socket.h, if the appropriate value can be determined;
however, given that the erroneous definition was not caught, it is
unlikely that any software actually attempts to use SCM_SRCRT.
Rich Felker [Wed, 8 Jan 2014 22:37:05 +0000 (17:37 -0500)]
fix inadvertent use of struct in place of union for semun
Szabolcs Nagy [Wed, 8 Jan 2014 21:52:26 +0000 (22:52 +0100)]
add __isoc99_vfscanf weak alias to vfscanf
this glibc abi compatibility function was missed when the scanf
aliases were added.
Szabolcs Nagy [Wed, 8 Jan 2014 21:51:46 +0000 (22:51 +0100)]
math: add drem and dremf weak aliases to i386 remainder asm
weak_alias was only in the c code, so drem was missing on platforms
where remainder is implemented in asm.
Rich Felker [Wed, 8 Jan 2014 21:12:47 +0000 (16:12 -0500)]
fix type of semctl variadic argument
per POSIX, the variadic argument has type union semun, which may
contain a pointer or int; the type read depends on the command being
issued. this allows the userspace part of the implementation to be
type-correct without requiring special-casing for different commands.
the kernel always expects to receive the argument interpreted as
unsigned long (or equivalently, a pointer), and does its own handling
of extracting the int portion from the representation, as needed.
this change fixes two possible issues: most immediately, reading the
argument as a (signed) long and passing it to the syscall would
perform incorrect sign-extension of pointers on the upcoming x32
target. the other possible issue is that some archs may use different
(user-space) argument-passing convention for unions, preventing va_arg
from correctly obtaining the argument when the type long (or even
unsigned long or void *) is passed to it.
Rich Felker [Wed, 8 Jan 2014 07:18:06 +0000 (02:18 -0500)]
in fcntl, avoid passing pointer arguments to syscalls as longs
really, fcntl should be changed to use the correct type corresponding
to cmd when calling va_arg, and to carry the correct type through
until making the syscall. however, this greatly increases binary size
and does not seem to offer any benefits except formal correctness, so
I'm holding off on that change for now.
the minimal changes made in this patch are in preparation for addition
of the x32 port, where the syscall macros need to know whether their
arguments are pointers or integers in order to properly pass them to
the 64-bit kernel.
Rich Felker [Tue, 7 Jan 2014 08:02:14 +0000 (03:02 -0500)]
fix const-correctness of argument to stime
it's unclear what the historical signature for this function was, but
semantically, the argument should be a pointer to const, and this is
what glibc uses. correct programs should not be using this function
anyway, so it's unlikely to matter.
Rich Felker [Tue, 7 Jan 2014 07:58:28 +0000 (02:58 -0500)]
fix signedness of pgoff argument to remap_file_pages
both the kernel and glibc agree that this argument is unsigned; the
incorrect type ssize_t came from erroneous man pages.
Rich Felker [Tue, 7 Jan 2014 07:50:34 +0000 (02:50 -0500)]
fix const-correctness in sigandset/sigorset arguments
this change is consistent with the corresponding glibc functions and
is semantically const-correct. the incorrect argument types without
const seem to have been taken from erroneous man pages.
Rich Felker [Tue, 7 Jan 2014 07:44:47 +0000 (02:44 -0500)]
remove sys/sysctl.h
this functionality has essentially always been deprecated in linux,
and was never supported by musl. the presence of the header was
reported to cause some software to attempt to use the nonexistant
function, so removing the header is the cleanest solution.
Rich Felker [Tue, 7 Jan 2014 07:41:27 +0000 (02:41 -0500)]
fix incorrect type for wd argument of inotify_rm_watch
this was wrong since the original commit adding inotify, and I don't
see any explanation for it. not even the man pages have it wrong. it
was most likely a copy-and-paste error.
Rich Felker [Tue, 7 Jan 2014 03:17:24 +0000 (22:17 -0500)]
fix argument types for legacy function inet_makeaddr
the type int was taken from seemingly erroneous man pages. glibc uses
in_addr_t (uint32_t), and semantically, the arguments should be
unsigned.
Rich Felker [Tue, 7 Jan 2014 03:05:54 +0000 (22:05 -0500)]
eliminate explicit (long) casts when making syscalls
this practice came from very early, before internal/syscall.h defined
macros that could accept pointer arguments directly and handle them
correctly. aside from being ugly and unnecessary, it looks like it
will be problematic when we add support for 32-bit ABIs on archs where
registers (and syscall arguments) are 64-bit, e.g. x32 and mips n32.
Rich Felker [Tue, 7 Jan 2014 03:03:38 +0000 (22:03 -0500)]
const-qualify the address argument to dladdr
this agrees with implementation practice on glibc and BSD systems, and
is the const-correct way to do things; it eliminates warnings from
passing pointers to const. the prototype without const came from
seemingly erroneous man pages.
Rich Felker [Tue, 7 Jan 2014 02:31:17 +0000 (21:31 -0500)]
add some missing LFS64 aliases for fadvise/fallocate functions
Rich Felker [Fri, 3 Jan 2014 19:33:44 +0000 (14:33 -0500)]
release 0.9.15
rofl0r [Fri, 3 Jan 2014 10:27:46 +0000 (11:27 +0100)]
fanotify.c: fix typo in header inclusion
the header is included only as a guard to check that the declaration
and definition match, so the typo didn't cause any breakage aside
from omitting this check.
Rich Felker [Thu, 2 Jan 2014 22:13:19 +0000 (17:13 -0500)]
disable the brk function
the reasons are the same as for sbrk. unlike sbrk, there is no safe
usage because brk does not return any useful information, so it should
just fail unconditionally.
Rich Felker [Thu, 2 Jan 2014 22:03:34 +0000 (17:03 -0500)]
disable sbrk for all values of increment except 0
use of sbrk is never safe; it conflicts with malloc, and malloc may be
used internally by the implementation basically anywhere. prior to
this change, applications attempting to use sbrk to do their own heap
management simply caused untrackable memory corruption; now, they will
fail with ENOMEM allowing the errors to be fixed.
sbrk(0) is still permitted as a way to get the current brk; some
misguided applications use this as a measurement of their memory
usage or for other related purposes, and such usage is harmless.
eventually sbrk may be re-added if/when malloc is changed to avoid
using the brk by using mmap for all allocations.
rofl0r [Thu, 2 Jan 2014 21:10:45 +0000 (22:10 +0100)]
add fanotify syscall wrapper and header
Timo Teräs [Wed, 25 Dec 2013 11:33:46 +0000 (13:33 +0200)]
fix struct signalfd_siginfo
ssi_ptr is really 64-bit in kernel, so fix that. assuming sizeof(void*)
for it also caused incorrect padding for 32-bits, as the following
64-bits are aligned to 64-bits (and the padding was not taken into
account), so fix the padding as well. add addr_lsb field while there.
Rich Felker [Fri, 20 Dec 2013 16:56:16 +0000 (11:56 -0500)]
implement legacy function herror
based on patch by Timo Teräs; greatly simplified to use fprintf.
Rich Felker [Fri, 20 Dec 2013 16:52:10 +0000 (11:52 -0500)]
add sys/quota.h and quotactl syscall wrapper
based on patch by Timo Teräs.
Rich Felker [Fri, 20 Dec 2013 16:42:03 +0000 (11:42 -0500)]
add netinet/igmp.h and multicast groups to netinet/in.h
based on patch by Timo Teräs.
Timo Teräs [Wed, 18 Dec 2013 11:53:11 +0000 (13:53 +0200)]
add TCP_INFO and TCP_MD5SIG socket option related structures
Rich Felker [Thu, 19 Dec 2013 19:24:55 +0000 (14:24 -0500)]
fix failure of fchmod, fstat, fchdir, and fchown to produce EBADF
the workaround/fallback code for supporting O_PATH file descriptors
when the kernel lacks support for performing these operations on them
caused EBADF to get replaced by ENOENT (due to missing entry in
/proc/self/fd). this is unlikely to affect real-world code (calls that
might yield EBADF are generally unsafe, especially in library code)
but it was breaking some test cases.
the fix I've applied is something of a tradeoff: it adds one syscall
to these operations on kernels where the workaround is needed. the
alternative would be to catch ENOENT from the /proc lookup and
translate it to EBADF, but I want to avoid doing that in the interest
of not touching/depending on /proc at all in these functions as long
as the kernel correctly supports the operations. this is following the
general principle of isolating hacks to code paths that are taken on
broken systems, and keeping the code for correct systems completely
hack-free.
Rich Felker [Thu, 19 Dec 2013 10:05:13 +0000 (05:05 -0500)]
fix hangs in localtime for near-overflowing time_t values on 64-bit archs
Rich Felker [Sun, 15 Dec 2013 00:51:48 +0000 (19:51 -0500)]
fix dynamic linker entry point for microblaze
the ABI allows the callee to clobber stack slots that correspond to
arguments passed in registers, so the caller must adjust the stack
pointer to reserve space appropriately. prior to this fix, the argv
array was possibly clobbered by dynamic linker code before passing
control to the main program.
Rich Felker [Fri, 13 Dec 2013 07:25:09 +0000 (02:25 -0500)]
optimize get_current_dir_name to reduce stack bloat
our getcwd already (as an extension) supports allocation of a buffer
when the buffer argument is a null pointer, so there's no need to
duplicate the allocation logic in this wrapper function. duplicating
it is actually harmful in that it doubles the stack usage from
PATH_MAX to 2*PATH_MAX.
Rich Felker [Fri, 13 Dec 2013 07:20:07 +0000 (02:20 -0500)]
use 0 instead of NULL for null pointer constants
and thereby remove otherwise-unnecessary inclusion of stddef.h
Szabolcs Nagy [Thu, 12 Dec 2013 05:09:18 +0000 (05:09 +0000)]
include cleanups: remove unused headers and add feature test macros
Szabolcs Nagy [Thu, 12 Dec 2013 04:18:34 +0000 (04:18 +0000)]
remove an unnecessary check in inet_pton
at most 4 hexadecimal digits are processed in one field so the
value cannot overflow. the netdb.h header was not used.
Szabolcs Nagy [Thu, 12 Dec 2013 03:42:11 +0000 (03:42 +0000)]
math: define _GNU_SOURCE when implementing non-standard math functions
this makes the prototypes in math.h are visible so they are checked agaist
the function definitions
Rich Felker [Sat, 7 Dec 2013 02:59:01 +0000 (21:59 -0500)]
add posix_close, accepted for inclusion in the next issue of POSIX
this is purely a wrapper for close since Linux does not support EINTR
semantics for the close syscall.
Rich Felker [Wed, 4 Dec 2013 23:00:19 +0000 (18:00 -0500)]
remove dependency of version.h on .git/* to avoid errors
the wildcard function in GNU make includes dangling symlinks; if any
exist under the .git directory, they would get added as dependencies,
causing make to exit with an error due to lacking a rule to build the
missing file.
as far as I can tell, git operations which should force version.h to
be rebuilt must all touch the mtime of the top-level .git directory.
Szabolcs Nagy [Wed, 4 Dec 2013 21:39:52 +0000 (21:39 +0000)]
move struct ucred under _GNU_SOURCE in sys/socket.h for clean posix namespace
Szabolcs Nagy [Wed, 4 Dec 2013 21:38:32 +0000 (21:38 +0000)]
fix SHUT_WR typo in sys/socket.h and duplicate definitions of SHUT_*
Szabolcs Nagy [Wed, 4 Dec 2013 21:31:39 +0000 (21:31 +0000)]
fix res_mkquery and res_send prototypes in resolv.h
historically these functions appeared in BSD 4.3 without prototypes,
then in the bind project prototypes were added to resolv.h, but those
were incompatible with the definitions of the implementation.
the bind resolv.h became the defacto api most systems use now, but the
old internal definitions found their way into the linux manuals and thus
into musl.
Rich Felker [Wed, 4 Dec 2013 01:34:36 +0000 (20:34 -0500)]
remove duplicate definition of _PATH_LASTLOG in paths.h
Rich Felker [Wed, 4 Dec 2013 00:01:40 +0000 (19:01 -0500)]
fix mv usage in install.sh to avoid bogus interactive prompting
Rich Felker [Mon, 2 Dec 2013 07:45:10 +0000 (02:45 -0500)]
workaround clang deficiency affecting thread pointer access on powerpc
based on patch by Richard Pennington, who initially reported the
issue.
Rich Felker [Mon, 2 Dec 2013 07:08:41 +0000 (02:08 -0500)]
implement FNM_LEADING_DIR extension flag in fnmatch
previously this flag was defined and accepted as a no-op, possibly
breaking some software that uses it. given the choice to remove the
definition and possibly break applications that were already working,
or simply implement the feature, the latter turned out to be easy
enough to make the decision easy.
in the case where the FNM_PATHNAME flag is also set, this
implementation is clean and essentially optimal. otherwise, it's an
inefficient "brute force" implementation. at some point, when cleaning
up and refactoring this code, I may add a more direct code path for
handling FNM_LEADING_DIR in the non-FNM_PATHNAME case, but at this
point my main interest is avoiding introducing new bugs in the code
that implements the standard fnmatch features specified by POSIX.
Rich Felker [Mon, 2 Dec 2013 07:06:52 +0000 (02:06 -0500)]
remove now-unnecessary features.h inclusion from fnmatch.h
Rich Felker [Mon, 2 Dec 2013 07:04:58 +0000 (02:04 -0500)]
expose FNM_* extensions in fnmatch.h without _GNU_SOURCE
at least a couple of these are used on BSD too, and the FNM_*
namespace is reserved in fnmatch.h anyway.
Rich Felker [Mon, 2 Dec 2013 04:16:38 +0000 (23:16 -0500)]
fix typos in INSTALL file
Rich Felker [Sun, 1 Dec 2013 22:27:25 +0000 (17:27 -0500)]
add infrastructure to record and report the version of libc.so
this is still experimental and subject to change. for git checkouts,
an attempt is made to record the exact revision to aid in bug reports
and debugging. no version information is recorded in the static libc.a
or binaries it's linked into.
Rich Felker [Sun, 1 Dec 2013 19:36:22 +0000 (14:36 -0500)]
fix fnmatch corner cases related to escaping
the FNM_PATHNAME logic for advancing by /-delimited components was
incorrect when the / character was escaped (i.e. \/), and a final \ at
the end of pattern was not handled correctly.
Szabolcs Nagy [Sun, 1 Dec 2013 17:32:48 +0000 (17:32 +0000)]
fix the end of string matching in fnmatch with FNM_PATHNAME
a '/' in the pattern could be incorrectly matched against the
terminating null byte in the string causing arbitrarily long
sequence of out-of-bounds access in fnmatch("/","",FNM_PATHNAME)
Rich Felker [Sat, 30 Nov 2013 18:33:29 +0000 (13:33 -0500)]
support mix of IPv4 and v6 nameservers in resolv.conf
a v6 socket will only be used if there is at least one v6 nameserver
address. if the kernel lacks v6 support, the code will fall back to
using a v4 socket and requests to v6 servers will silently fail. when
using a v6 socket, v4 addresses are converted to v4-mapped form and
setsockopt is used to ensure that the v6 socket can accept both v4 and
v6 traffic (this is on-by-default on Linux but the default is
configurable in /proc and so it needs to be set explicitly on the
socket level). this scheme avoids increasing resource usage during
lookups and allows the existing network io loop to be used without
modification.
previously, nameservers whose address family did not match the address
family of the first-listed nameserver were simply ignored. prior to
recent __ipparse fixes, they were not ignored but erroneously parsed.
Rich Felker [Fri, 29 Nov 2013 17:45:09 +0000 (12:45 -0500)]
increase TTY_NAME_MAX limit to 32
the old value of 20 was reported by Laurent Bercot as being
insufficient for a reasonable real-world usage case. actual problem
was the internal buffer used by ttyname(), but the implementation of
ttyname uses TTY_NAME_MAX, and for consistency it's best to increase
both. the new value is aligned with glibc.
Rich Felker [Wed, 27 Nov 2013 05:54:03 +0000 (00:54 -0500)]
reject invalid address families in getaddrinfo
subsequent code assumes the address family requested is either
unspecified or one of IPv4/IPv6, and could malfunction if this
constraint is not met, so other address families should be explicitly
rejected.
Rich Felker [Wed, 27 Nov 2013 04:26:37 +0000 (23:26 -0500)]
adjust fallback INFINITY definition for FLT_EVAL_METHOD==2 case
on archs with excess precision, the floating point constant 1e40f may
be evaluated such that it does not actually produce an infinity.
1e5000f is sufficiently large to produce an infinity for all supported
floating point formats. note that this definition of INFINITY is only
used for old or non-GNUC compilers anyway; despite being a portable,
conforming definition, it leads to erroneous warnings on many
compilers and thus using the builtin is preferred.
Rich Felker [Wed, 27 Nov 2013 01:01:21 +0000 (20:01 -0500)]
fix off-by-one length failure in strftime/wcsftime and improve error behavior
these functions were spuriously failing in the case where the buffer
size was exactly the number of bytes/characters to be written,
including null termination. since these functions do not have defined
error conditions other than buffer size, a reasonable application may
fail to check the return value when the format string and buffer size
are known to be valid; such an application could then attempt to use a
non-terminated buffer.
in addition to fixing the bug, I have changed the error handling
behavior so that these functions always null-terminate the output
except in the case where the buffer size is zero, and so that they
always write as many characters as possible before failing, rather
than dropping whole fields that do not fit. this actually simplifies
the logic somewhat anyway.
Szabolcs Nagy [Mon, 25 Nov 2013 23:34:10 +0000 (23:34 +0000)]
remove duplicate includes from dynlink.c, strfmon.c and getaddrinfo.c
Rich Felker [Mon, 25 Nov 2013 02:42:55 +0000 (21:42 -0500)]
restore type of NULL to void * except when used in C++ programs
unfortunately this eliminates the ability of the compiler to diagnose
some dangerous/incorrect usage, but POSIX requires (as an extension to
the C language, i.e. CX shaded) that NULL have type void *. plain C
allows it to be defined as any null pointer constant.
the definition 0L is preserved for C++ rather than reverting to plain
0 to avoid dangerous behavior in non-conforming programs which use
NULL as a variadic sentinel. (it's impossible to use (void *)0 for C++
since C++ lacks the proper implicit pointer conversions, and other
popular alternatives like the GCC __null extension seem non-conforming
to the standard's requirements.)
Michael Forney [Thu, 21 Nov 2013 03:13:41 +0000 (19:13 -0800)]
shadow: Implement fgetspent
Michael Forney [Sun, 24 Nov 2013 06:17:42 +0000 (22:17 -0800)]
shadow: Move spent parsing to internal function
Michael Forney [Sun, 24 Nov 2013 06:33:05 +0000 (22:33 -0800)]
Fix dn_comp prototype and add stub
This function is used by ping6 from iputils.
Michael Forney [Sun, 24 Nov 2013 06:10:10 +0000 (22:10 -0800)]
shadow: Implement putspent
Szabolcs Nagy [Sun, 24 Nov 2013 01:06:38 +0000 (01:06 +0000)]
math: clean up __rem_pio2
- remove the HAVE_EFFICIENT_IRINT case: fn is an exact integer, so
it can be converted to int32_t a bit more efficiently than with a
cast (the rounding mode change can be avoided), but musl does not
support this case on any arch.
- __rem_pio2: use double_t where possible
- __rem_pio2f: use less assignments to avoid stores on i386
- use unsigned int bit manipulation (and union instead of macros)
- use hexfloat literals instead of named constants
Szabolcs Nagy [Sun, 24 Nov 2013 00:34:07 +0000 (00:34 +0000)]
use 0 instead of NULL in headers where NULL is not defined
some macros in sys/mtio.h and syslog.h used NULL without defining it
Szabolcs Nagy [Sat, 23 Nov 2013 23:47:48 +0000 (23:47 +0000)]
add O_TMPFILE flag, new in linux 3.11
definition in linux:
#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
where __O_TMPFILE and O_DIRECTORY are arch specific
Szabolcs Nagy [Sat, 23 Nov 2013 23:04:55 +0000 (23:04 +0000)]
add TCP_NOTSENT_LOWAT tcp socket option, new in linux v3.12
Timo Teräs [Mon, 14 Oct 2013 05:28:19 +0000 (08:28 +0300)]
add linux tcp state enums
Timo Teräs [Wed, 31 Jul 2013 09:05:14 +0000 (12:05 +0300)]
add multicast structures from RFC 3678 to netinet/in.h
and use _GNU_SOURCE || _BSD_SOURCE guards for all of the RFC 3678
namespace polluting things like glibc/uclibc does.
Michael Forney [Tue, 5 Nov 2013 05:43:57 +0000 (21:43 -0800)]
Fix dn_expand pointer following
Michael Forney [Tue, 5 Nov 2013 07:34:21 +0000 (23:34 -0800)]
putgrent: Add missing newline
Michael Forney [Tue, 5 Nov 2013 07:34:20 +0000 (23:34 -0800)]
putgrent: Stop writing output on first failure
This way, if an fprintf fails, we get an incomplete group entry rather
than a corrupted one.
Michael Forney [Tue, 5 Nov 2013 05:48:08 +0000 (21:48 -0800)]
strcmp: Remove unnecessary check for *r
If *l == *r && *l, then by transitivity, *r.
rofl0r [Sat, 23 Nov 2013 12:01:53 +0000 (13:01 +0100)]
timeradd/timersub: cast result to void to get rid of warnings
previously:
timersub(&now, t, &diff);
warning: value computed is not used [-Wunused-value]
Rich Felker [Fri, 22 Nov 2013 21:29:31 +0000 (16:29 -0500)]
fix and refactor child reaping logic in wordexp
loop condition was incorrect and confusing and caused an infinite loop
when (broken) applications reaped the pid from a signal handler or
another thread before wordexp's call to waitpid could do so.
Rich Felker [Fri, 22 Nov 2013 20:55:58 +0000 (15:55 -0500)]
fix fd leak and case where fd 1 is already closed in wordexp
Rich Felker [Fri, 22 Nov 2013 20:48:24 +0000 (15:48 -0500)]
fix resource exhaustion and zero-word cases in wordexp
when WRDE_NOSPACE is returned, the we_wordv and we_wordc members must
be valid, because the interface contract allows them to return partial
results.
in the case of zero results (due either to resource exhaustion or a
zero-word input) the we_wordv array still should contain a terminating
null pointer and the initial we_offs null pointers. this is impossible
on resource exhaustion, so a correct application must presumably check
for a null pointer in we_wordv; POSIX however seems to ignore the
issue. the previous code may have crashed under this situation.
Rich Felker [Fri, 22 Nov 2013 20:29:14 +0000 (15:29 -0500)]
improve robustness of wordexp and fix handling of 0-word case
avoid using exit status to determine if a shell error occurred, since
broken programs may install SIGCHLD handlers which reap all zombies,
including ones that don't belong to them. using clone and __WCLONE
does not seem to work for avoiding this problem since exec resets the
exit signal to SIGCHLD.
instead, the new code uses a dummy word at the beginning of the
shell's output, which is ignored, to determine whether the command was
executed successfully. this also fixes a corner case where a word
string containing zero words was interpreted as a single zero-length
word rather than no words at all. POSIX does not seem to require this
case to be supported anyway, though.
in addition, the new code uses the correct retry idiom for waitpid to
ensure that spurious STOP/CONT signals in the child and/or EINTR in
the parent do not prevent successful wait for the child, and blocks
signals in the child.
Szabolcs Nagy [Thu, 21 Nov 2013 01:59:43 +0000 (01:59 +0000)]
add legacy getloadavg api
Rich Felker [Thu, 21 Nov 2013 01:34:33 +0000 (20:34 -0500)]
fix fd leak (missing close-on-exec) in getifaddrs
Szabolcs Nagy [Thu, 21 Nov 2013 01:16:49 +0000 (01:16 +0000)]
math: add (obsolete) bsd drem and finite functions
Szabolcs Nagy [Thu, 21 Nov 2013 01:01:57 +0000 (01:01 +0000)]
math: lgamma cleanup (simpler sin(pi*x) for the negative case)
* simplify sin_pi(x) (don't care about inexact here, the result is
inexact anyway, and x is not so small to underflow)
* in lgammal add the previously removed special case for x==1 and
x==2 (to fix the sign of zero in downward rounding mode)
* only define lgammal on supported long double platforms
* change tgamma so the generated code is a bit smaller
Rich Felker [Wed, 20 Nov 2013 23:28:18 +0000 (18:28 -0500)]
fix the nominal type of LDBL_* limits on archs with ld64
previously these macros wrongly had type double rather than long
double. I see no way an application could detect the error in C99, but
C11's _Generic can trivially detect it.
at the same time, even though these archs do not have excess
precision, the number of decimal places used to represent these
constants has been increased to 21 to be consistent with the decimal
representations used for the DBL_* macros.
Rich Felker [Wed, 20 Nov 2013 22:40:33 +0000 (17:40 -0500)]
write floating point limit constants to 21 significant decimal places
this is enough to produce the correct value even if the constant is
interpreted as 80-bit extended precision, which matters on archs with
excess precision (FLT_EVAL_METHOD==2) under at least some
interpretations of the C standard. the shorter representations, while
correct if converted to the nominal precision at translation time,
could produce an incorrect value at extended precision, yielding
results such as (double)DBL_MAX != DBL_MAX.
rofl0r [Mon, 11 Nov 2013 04:44:47 +0000 (05:44 +0100)]
iswspace: fix handling of 0
Rich Felker [Sat, 9 Nov 2013 22:54:20 +0000 (17:54 -0500)]
fix harmless inconsistency in semtimedop
this should not matter since the reality is that either all the sysv
sem syscalls are individual syscalls, or all of them are multiplexed
on the SYS_ipc syscall (depending on arch). but best to be consistent
anyway.
Rich Felker [Sat, 9 Nov 2013 05:18:57 +0000 (00:18 -0500)]
implement semtimedop
this is a Linux-specific extension to the sysv semaphore api.
Rich Felker [Sat, 9 Nov 2013 05:04:02 +0000 (00:04 -0500)]
adjust sys/wait.h not to produde errors in strict ISO C feature profile
siginfo_t is not available from signal.h when the strict ISO C feature
profile (e.g. passing -std=c99 to gcc without defining any other
feature test macros) is used, but the type is needed to declare
waitid. using sys/wait.h (or any POSIX headers) in strict ISO C mode
is an application bug, but in the interest of compatibility, it's best
to avoid producing gratuitous errors. the simplest fix I could find is
suppressing the declaration of waitid (and also signal.h inclusion,
since it's not needed for anything else) in this case, while still
exposing everything else in sys/wait.h
Rich Felker [Sat, 9 Nov 2013 02:33:42 +0000 (21:33 -0500)]
remove O_NOFOLLOW from __map_file used for time zone file loading
it's not clear why I originally wrote O_NOFOLLOW into this; I suspect
the reason was with an aim of making the function more general for
mapping partially or fully untrusted files provided by the user.
however, the timezone code already precludes use of absolute or
relative pathnames in suid/sgid programs, and disallows .. in
pathnames which are relative to one of the system timezone locations,
so there is no threat of opening a symlink which is not trusted by
appropriate user. since some users may wish to put symbolic links in
the zoneinfo directories to alias timezones, it seems preferable to
allow this.
Rich Felker [Sat, 9 Nov 2013 01:50:59 +0000 (20:50 -0500)]
fix handling of overly-long TZ environment variable values
the rest of the code is not prepared to handle an empty TZ string, so
falling back to __gmt ("GMT"), just as if TZ had been blank or unset,
is the preferable action.
rofl0r [Mon, 4 Nov 2013 17:07:28 +0000 (17:07 +0000)]
timezone parser: fix iteration over search dir paths
try+l points to \0, so only one iteration was ever tried.
rofl0r [Mon, 4 Nov 2013 15:57:51 +0000 (15:57 +0000)]
timezone parser: fix offset to transition table in 64bit code path
we need to skip to the second TZif header, which starts at
skip+44, and then skip another header (20 bytes) plus the following
6 32bit values.
rofl0r [Mon, 4 Nov 2013 15:13:21 +0000 (15:13 +0000)]
fix timezone parser code crashing on 64bit sys
if sizeof(time_t) == 8, this code path was missing the correct
offset into the zoneinfo file, using the header magic to do
offset calculations.
the 6 32bit fields to be read start at offset 20.
Rich Felker [Sat, 2 Nov 2013 08:07:12 +0000 (04:07 -0400)]
fix regression in inet_aton due to misinterpretation of __ipparse return
inet_aton returns a boolean success value, whereas __ipparse returns 0
on success and -1 on failure. also change the conditional in inet_addr
to be consistent with other uses of __ipparse where only negative
values are treated as failure.
Rich Felker [Sat, 2 Nov 2013 00:34:05 +0000 (20:34 -0400)]
simplify faccessat AT_EACCESS path and eliminate resource dependence
now that we're waiting for the exit status of the child process, the
result can be conveyed in the exit status rather than via a pipe.
since the error value might not fit in 7 bits, a table is used to
translate possible meaningful error values to small integers.
Rich Felker [Fri, 1 Nov 2013 21:01:52 +0000 (17:01 -0400)]
fix faccessat AT_EACCESS path not to leave zombie processes
I mistakenly assumed that clone without a signal produced processes
that would not become zombies; however, waitpid with __WCLONE is
required to release their pids.
Rich Felker [Wed, 30 Oct 2013 18:52:55 +0000 (14:52 -0400)]
fix inttypes.h PRI and SCN macros for [u]intptr_t types
while using "l" unconditionally gave the right behavior due to
matching sizes/representations, it was technically UB and produced
compiler warnings with format string checking.