|Age||Commit message (Collapse)||Author||Lines|
Internally regcomp needs to copy some iteration nodes before
translating the AST into TNFA representation.
Literal nodes were not copied correctly: the class type and list
of negated class types were not copied so classes were ignored
(in the non-negated case an ignored char class caused the literal
to match everything).
This affects iterations when the upper bound is finite, larger
than one or the lower bound is larger than one. So eg. the EREs
were treated as
The fix is done with minimal source modification to copy the
necessary fields, but the AST preparation and node handling
code of tre will need to be cleaned up for clarity.
(cherry picked from commit c498efe117539a9d40d90b588c033316701c4b3e)
one stop condition for parsing abbreviated ipv6 addressed was missed,
allowing the internal ip buffer to overflow. this patch adds the
missing stop condition and masks the array index so that, in case
there are any remaining stop conditions missing, overflowing the
buffer is not possible.
(cherry picked from commit fc13acc3dcb5b1f215c007f583a63551f6a71363)
the regex parser handles the (undefined) case of an unexpected byte
following a backslash as a literal. however, instead of correctly
decoding a character, it was treating the byte value itself as a
character. this was not only semantically unjustified, but turned out
to be dangerous on archs where plain char is signed: bytes in the
range 252-255 alias the internal codes -4 through -1 used for special
types of literal nodes in the AST.
analogous to commit 39dfd58417ef642307d90306e1c7e50aaec5a35c in
mainline. it's unclear whether the same crash that affected mainline
is possible in the older regcomp code in 1.0.x, but conceptually the
bug is the same.
(cherry picked from commit 380857bf21bcffbbee2fe8ab52feadf39366d7ec)
the malloc init code provided its own version of pthread_once type
logic, including the exact same bug that was fixed in pthread_once in
since this code is called adjacent to expand_heap, which takes a lock,
there is no reason to have pthread_once-type initialization. simply
moving the init code into the interval where expand_heap already holds
its lock on the brk achieves the same result with much less
synchronization logic, and allows the buggy code to be eliminated
rather than just fixed.
(cherry picked from commit 7a81fe3710be0128d29071e76c5acbea3d84277b)
this issue mainly affects PIE binaries and execution of programs via
direct invocation of the dynamic linker binary: depending on kernel
behavior, in these cases the initial brk may be placed at at location
where it cannot be extended, due to conflicting adjacent maps.
when brk fails, mmap is used instead to expand the heap. in order to
avoid expensive bookkeeping for managing fragmentation by merging
these new heap regions, the minimum size for new heap regions
increases exponentially in the number of regions. this limits the
number of regions, and thereby the number of fixed fragmentation
points, to a quantity which is logarithmic with respect to the size of
virtual address space and thus negligible. the exponential growth is
tuned so as to avoid expanding the heap by more than approximately 50%
of its current total size.
(cherry picked from commit 5446303328adf4b4e36d9fba21848e6feb55fab4)
the character sequence '$((' was incorrectly interpreted as the
opening of arithmetic even within single-quoted contexts, thereby
suppressing the checks for bad characters after the closing quote.
presently bad character checking is only performed when the WRDE_NOCMD
is used; this patch only corrects checking in that case.
(cherry picked from commit 594ffed82f4e6ee7da85e9c5da35e32946ae32c9)
mips fesetenv did not handle FE_DFL_ENV, now fcsr is cleared in that
(cherry picked from commit 5fc1487832e16aa2119e735a388d5f36c8c139e2)
in the case where a non-symlink file was replaced by a symlink during
the fchmodat operation with AT_SYMLINK_NOFOLLOW, mode change on the
new symlink target was successfully suppressed, but the error was not
reported. instead, fchmodat simply returned 0.
(cherry picked from commit 61b1d102129990f6e903c6ddcf46c7d79d1a1e99)
(conflicts from commit dd5f50da6f6c3df5647e922e47f8568a8896a752)
(cherry picked from commit 2736eb6caa70bb6e909d7d8ebbe145c2071435e0)
when using /etc/shadow (rather than tcb) as its backend, getspnam_r
matched any username starting with the caller-provided string rather
than requiring an exact match. in practice this seems to have affected
only systems where one valid username is a prefix for another valid
username, and where the longer username appears first in the shadow
(cherry picked from commit ecb608192a48d3688e1a0a21027bfd968d3301a1)
based on patch by Dima Krasner, with minor improvements for code size.
connect can fail if there is no listening syslogd, in which case a
useless socket was kept open, preventing subsequent syslog call from
attempting to connect again.
(cherry picked from commit c574321d75f035ff6d2c18dfb7e3f70db60ba7bd)
previously, write errors neither stopped further output attempts nor
caused the function to return an error to the caller. this could
result in silent loss of output, possibly in the middle of output in
the event of a non-permanent error.
the simplest solution is temporarily clearing the error flag for the
target stream, then suppressing further output when the error flag is
set and checking/restoring it at the end of the operation to determine
the correct return value.
since the wide version of the code internally calls the narrow fprintf
to perform some of its underlying operations, initial clearing of the
error flag is suppressed when performing a narrow vfprintf on a
wide-oriented stream. this is not a problem since the behavior of
narrow operations on wide-oriented streams is undefined.
(cherry picked from commit d42269d7c85308abdbf8cee38b1a1097249eb38b)
these functions are expected to return an error code rather than
setting errno and returning -1.
(cherry picked from commit 66140b0c926ed097f2cb7474863523e4af351f5b)
the sched_getaffinity syscall only fills a cpu set up to the set size
used/supported by the kernel. the rest is left untouched and userspace
is responsible for zero-filling it based on the return value of the
(cherry picked from commit a56e339419c1a90f8a85f86621f3c73945e07b23)
the new DT_RUNPATH semantics for search order are always used, and
since binutils had always set both DT_RPATH and DT_RUNPATH when the
latter was used, processing only DT_RPATH worked fine. however, recent
binutils has stopped generating DT_RPATH when DT_RUNPATH is used,
which broke support for this feature completely.
(cherry picked from commit d8dc2b7c0289b12eeef4feff65e3c918111b0f55)
in this case there are two conflicting rules in play: that an explicit
precision of zero with the value zero produces no output, and that the
'#' modifier for octal increases the precision sufficiently to yield a
leading zero. ISO C (126.96.36.199 paragraph 6 in C99+TC3) includes a
parenthetical remark to clarify that the precision-increasing behavior
takes precedence, but the corresponding text in POSIX off of which I
based the implementation is missing this remark.
this issue was covered in WG14 DR#151.
(cherry picked from commit b91cdbe2bc8b626aa04dc6e3e84345accf34e4b1)
Some early x86_64 cpus (released before 2006) did not support sahf/lahf
instructions so they should be avoided (intel manual says they are only
supported if CPUID.80000001H:ECX.LAHF-SAHF[bit 0] = 1).
The workaround simplifies exp2l and expm1l because fucomip can be
used instead of the fucomp;fnstsw;sahf sequence copied from i386.
In fmodl and remainderl sahf is replaced by a simple bit test.
(cherry picked from commit a732e80d33b4fd6f510f7cec4f5573ef5d89bc4e)
this was introduced in commit 2da3ab1382ca8e39eb1e4428103764a81fba73d3
as an oversight while making the variadic argument access conditional.
(cherry picked from commit e146e6035fecea080fb17450db3c8bb44d36e07d)
the mode argument is only required to be present when the O_CREAT or
O_TMPFILE flag is used.
(cherry picked from commit 2da3ab1382ca8e39eb1e4428103764a81fba73d3)
these functions need to be fast when the init routine has already run,
since they may be called very often from code which depends on global
initialization having taken place. as such, a fast path bypassing
atomic cas on the once control object was used to avoid heavy memory
contention. however, on archs with weakly ordered memory, the fast
path failed to ensure that the caller actually observes the side
effects of the init routine.
preliminary performance testing showed that simply removing the fast
path was not practical; a performance drop of roughly 85x was observed
with 20 threads hammering the same once control on a 24-core machine.
so the new explicit barrier operation from atomic.h is used to retain
the fast path while ensuring memory visibility.
performance may be reduced on some archs where the barrier actually
makes a difference, but the previous behavior was unsafe and incorrect
on these archs. future improvements to the implementation of a_barrier
should reduce the impact.
(cherry picked from commit df37d3960abec482e17fad2274a99b790f6cc08b)
(edited not to depend on a_barrier, which is not available in 1.0.x)
previously, the hours were considered as a signed quantity while
minutes and seconds were always treated as positive offsets. however,
semantically the '-' sign should negate the whole hh:mm:ss offset.
this bug only affected timezones east of GMT with non-whole-hours
offsets, such as those used in India and Nepal.
(cherry picked from commit 08b996d180323775d5457944eefbb8a51ea72539)
this function is specified to leave the last byte with "unspecified
disposition" when the length is odd, so for the most part correct
programs should not be calling swab with odd lengths. however, doing
so is permitted, and should not write past the end of the destination
(cherry picked from commit dccbf4c809efc311aa37da71de70d04dfd8b0db3)
patch by Jens Gustedt. this fixes a bug reported by Nadav Har'El. the
underlying issue was that a left-shift by 16 bits after promotion of
unsigned short to int caused integer overflow. while some compilers
define this overflow case as "shifting into the sign bit", doing so
doesn't help; the sign bit then gets extended through the upper bits
in subsequent arithmetic as unsigned long long. this patch imposes a
promotion to unsigned prior to the shift, so that the result is
well-defined and matches the specified behavior.
(cherry picked from commit 05cef96d9e63a00b319f88343cf9869c8e612843)
incorrect behavior occurred only in cases where the input overflows
unsigned long long, not just the (possibly lower) range limit for the
result type. in this case, processing of the '-' sign character was
not suppressed, and the function returned a value of 1 despite setting
errno to ERANGE.
(cherry picked from commit e2e1bb81485a37321d928a8d8b63f40b9d8fa228)
(cherry picked from commit 546f6b322bcafa2452925c19f9607d9689c75f95)
this error resulted in an out-of-bounds read, as opposed to a reported
error, when calling the function with an argument one greater than the
max valid index.
(cherry picked from commit 3bed89aa7456d9fe30e550cb5e21f8911036695b)
previously, fgets, fputs, fread, and fwrite completely omitted locking
and access to the FILE object when their arguments yielded a zero
length read or write operation independent of the FILE state. this
optimization was invalid; it wrongly skipped marking the stream as
byte-oriented (a C conformance bug) and exposed observably missing
synchronization (a POSIX conformance bug) where one of these functions
could wrongly complete despite another thread provably holding the
(cherry picked from commit 6e2bb7acf42589fb7130b039d0623e2ca42503dd)
the C standard requires that "the contents of the array remain
unchanged" in this case.
this patch also changes the behavior on read errors, but in that case
"the array contents are indeterminate", so the application cannot
inspect them anyway.
(cherry picked from commit 402611c3ba3be5b3b0486835d98e22ac7ced2722)
Empty name was rejected in dn_expand since commit
which is a regression as reported by Natanael Copa.
Furthermore if an offset pointer in a compressed name
pointed to a terminating 0 byte (instead of a label)
the returned name was not null terminated.
(cherry picked from commit 49d2c8c6bcf8c926e52c7f510033b6adc31355f5)
the subsequent code in pthread_create and the code which copies TLS
initialization images to the new thread's TLS space assume that the
memory provided to them is zero-initialized, which is true when it's
obtained by pthread_create using mmap. however, when the caller
provides a stack using pthread_attr_setstack, pthread_create cannot
make any assumptions about the contents. simply zero-filling the
relevant memory in this case is the simplest and safest fix.
(cherry picked from commit a6293285e930dbdb0eff47e29b513ca22537b1a2)
these were removed from the standard but still offered as an extension
in langinfo.h, so nl_langinfo should support them.
(cherry picked from commit 0206f596d5156af560e8af10e950d3cb2f29b73d)
due to a skipped slot and missing null terminator, the last few
strings were off by one or two slots from their item codes.
(cherry picked from commit a19cd2b64aabee4ae3c80bcf4ba8da26fba560e4)
per POSIX, the nmatch and pmatch arguments are ignored when the regex
was compiled with REG_NOSUB.
(cherry picked from commit 72ed3d47e567b1635a35d3c1d174c8a8b2787e30)
previously we detected this bug in configure and issued advice for a
workaround, but this turned out not to work. since then gcc 4.9.0 has
appeared in several distributions, and now 4.9.1 has been released
without a fix despite this being a wrong code generation bug which is
supposed to be a release-blocker, per gcc policy.
since the scope of the bug seems to affect only data objects (rather
than functions) whose definitions are overridable, and there are only
a very small number of these in musl, I am just changing them from
const to volatile for the time being. simply removing the const would
be sufficient to make gcc 4.9.1 work (the non-const case was
inadvertently fixed as part of another change in gcc), and this would
also be sufficient with 4.9.0 if we forced -O0 on the affected files
or on the whole build. however it's cleaner to just remove all the
broken compiler detection and use volatile, which will ensure that
they are never constant-folded. the quality of a non-broken compiler's
output should not be affected except for the fact that these objects
are no longer const and thus possibly add a few bytes to data/bss.
this change can be reconsidered and possibly reverted at some point in
the future when the broken gcc versions are no longer relevant.
(cherry picked from commit a6adb2bcd8145353943377d6119c1d7a4242bae1)
the purpose of this logic is to avoid linking __stdio_exit unless any
stdio reads (which might require repositioning the file offset at exit
time) or writes (which might require flushing at exit time) could have
previously, exit called two wrapper functions for __stdio_exit named
__flush_on_exit and __seek_on_exit. both of these functions actually
performed both tasks (seek and flushing) by calling the underlying
__stdio_exit. in order to avoid doing this twice, an overridable data
object __towrite_used was used to cause __seek_on_exit to act as a nop
when __towrite was linked.
now, exit only makes one call, directly to __stdio_exit. this is
satisfiable by a weak dummy definition in exit.c, but the real
definition is pulled in by either __toread.c or __towrite.c through
their referencing a symbol which is defined only in __stdio_exit.c.
(cherry picked from commit c463e11eda8326aacee2ac1d516954a9574a2dcd)
errno must be saved upon vsyslog entry, otherwise its value could be
changed by some libc function before reaching the %m handler in
(cherry picked from commit da27118157c2942d7652138b8d8b0056fc8f872f)
(cherry picked from commit 349381aa8c0fc385e54e1068dd5f2b27af55cd12)
r24 was wrongly being saved at a misaligned offset of 30 rather than
the correct offset of 40 in the jmp_buf. the exact effects of this
error have not been studied, but it's clear that the value of r24 was
lost across setjmp/longjmp and the saved values of r21 and/or r22 may
also have been corrupted.
(cherry picked from commit 729673689c3e78803ddfdac2ca6be5a5b80e124a)
1. failure to output a newline after the password is read
2. fd leaks via missing FD_CLOEXEC
3. fd leaks via failure-to-close when any of the standard streams are
closed at the time of the call
4. wrongful fallback to use of stdin when opening /dev/tty fails
5. wrongful use of stderr rather than /dev/tty for prompt
6. failure to report error reading password
(cherry picked from commit ea496d6c63ecbb5ea475111808e5c0f799354450)
in some cases, these functions internally call a byte-based input or
output function before calling getwc/putwc, so they cannot rely on the
latter to set the orientation.
(cherry picked from commit 984c25b74da085c6ae6b44a87bbd5f8afc9be331)
when the orientation of the stream was already set, fwide was
incorrectly returning its argument (the requested orientation) rather
than the actual orientation of the stream.
(cherry picked from commit ebd8142a6ae19db1a5440d11c01afc7529eae0cd)
these functions were setting wc to point to wchar_t aliasing itself as
a "cheap" way to support null wc arguments. doing so was anything but
cheap, since even without the aliasing violation, it would limit the
compiler's ability to optimize.
making wc point to a dummy object is equally easy and does not suffer
from the above problems.
(cherry picked from commit e89cfe51d2001af08fc2a13e5133ba8157f90beb)
the logic for this loop was copied from null-terminated-string logic
in strstr without properly adapting it to work with explicit lengths.
presumably this error could result in false negatives (wrongly
comparing past the end of the needle/haystack), false positives
(stopping comparison early when the needle contains null bytes), and
crashes (from runaway reads past the end of mapped memory).
(cherry picked from commit cef0f289f666b6c963bfd11537a6d80916ff889e)
(cherry picked from commit 4e5c7a2176773c9a1564c6603240337b3ad6b496)
this change is harmless and allows commit
a6adb2bcd8145353943377d6119c1d7a4242bae1 to apply without conflicts.
according to the documentation in the man pages, the GNU extension
functions gethostbyaddr_r, gethostbyname_r and gethostbyname2_r are
guaranteed to set the result pointer to NULL in case of error or no
corresponds to commit fe82bb9b921be34370e6b71a1c6f062c20999ae0 in
Due to an error introduced in commit fcc522c92335783293ac19df318415cd97fbf66b,
checking of the remaining output buffer space was not performed correctly,
allowing malformed input to write past the end of the buffer.
In addition, the loop detection logic failed to account for the possibility
of infinite loops with no output, which would hang the function.
The output size is now limited more strictly so only names with valid length
(cherry picked from commit b3d9e0b94ea73c68ef4169ec82c898ce59a4e30a)
the service and protocol functions are defined also in other files,
and the protocol ones are actually non-nops elsewhere, so the weak
definitions in ent.c could have prevented the strong definitions from
getting pulled in and used in some static programs.
(cherry picked from commit 934aa1350b96461f205ad69c95e8f6f035f6b62c)
the return value is unsigned, so negative results for "errors" do not
make sense; 0 is the value reserved for when the interface name does
(cherry picked from commit 8041af59881219c32267c3491bee43591d3c3fe6)