<feed xmlns='http://www.w3.org/2005/Atom'>
<title>musl, branch master</title>
<subtitle>musl - an implementation of the standard library for Linux-based systems</subtitle>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/'/>
<entry>
<title>regex: avoid int overflow in regcomp</title>
<updated>2026-10-14T22:48:56+00:00</updated>
<author>
<name>Szabolcs Nagy</name>
<email>nsz@port70.net</email>
</author>
<published>2026-04-23T21:22:18+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=7813e9119eb5fe681b6750b8a033a0490bca0941'/>
<id>7813e9119eb5fe681b6750b8a033a0490bca0941</id>
<content type='text'>
regcomp has many int arith ops that may overflow. before tre_expand_ast
int values are limited by 2x the input length n, e.g.:

  input ERE        int field    max value
  aaaaaaaaaaaa...  position     n
  ()()()()()()...  submatch_id  n/2+1
  ()||||||||||...  num_tags     2n-3

so overflow before expand requires large n (and a lot of memory). later
some values can become big due to repetitions:

  input ERE                     int field that overflows
  (((a{255}){255}){255}){255}   position
  ((a|b*){255,}){255,}          num_transitions

num_transitions and memory use can be big without {k,} repetitions too:

  input ERE        what             max value
  (a|a|a|a...|a)*  num_transitions  n^2/4
  (()|a|a|...|a)*  sum tnfa tags    &gt; n^3/16 - n^2

so memory can run out quickly as n grows (with 31bit va space 1700 long
input is enough even without {k,}) about half is tnfa and half is ast
firstpos/lastpos data. but overflow can happen before allocations fail.

fix early overflow by limiting n. the stack usage is in [n,11n] without
repetitions, usually 7n, so the stack limit got adjusted too. the limit
is such that almost all inputs that worked before still work.

overflows during and after expand are fixed by explicit checks via a
check_add helper and xcalloc instead of xmalloc.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
regcomp has many int arith ops that may overflow. before tre_expand_ast
int values are limited by 2x the input length n, e.g.:

  input ERE        int field    max value
  aaaaaaaaaaaa...  position     n
  ()()()()()()...  submatch_id  n/2+1
  ()||||||||||...  num_tags     2n-3

so overflow before expand requires large n (and a lot of memory). later
some values can become big due to repetitions:

  input ERE                     int field that overflows
  (((a{255}){255}){255}){255}   position
  ((a|b*){255,}){255,}          num_transitions

num_transitions and memory use can be big without {k,} repetitions too:

  input ERE        what             max value
  (a|a|a|a...|a)*  num_transitions  n^2/4
  (()|a|a|...|a)*  sum tnfa tags    &gt; n^3/16 - n^2

so memory can run out quickly as n grows (with 31bit va space 1700 long
input is enough even without {k,}) about half is tnfa and half is ast
firstpos/lastpos data. but overflow can happen before allocations fail.

fix early overflow by limiting n. the stack usage is in [n,11n] without
repetitions, usually 7n, so the stack limit got adjusted too. the limit
is such that almost all inputs that worked before still work.

overflows during and after expand are fixed by explicit checks via a
check_add helper and xcalloc instead of xmalloc.
</pre>
</div>
</content>
</entry>
<entry>
<title>SIGEV_THREAD timers: fix deadlock when timer_create syscall fails</title>
<updated>2026-10-12T23:11:47+00:00</updated>
<author>
<name>Colin Cross</name>
<email>ccross@android.com</email>
</author>
<published>2026-09-02T20:38:08+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=f607123b7210b52ddfff7c8d5a8a9b84efbe2d6b'/>
<id>f607123b7210b52ddfff7c8d5a8a9b84efbe2d6b</id>
<content type='text'>
sem_wait is a cancellation point.  If the parent thread in timer_create
sets td-&gt;cancel = 1 before the child thread reaches sem_wait then
the thread will exit and sem_post will never be called, causing
the parent thread to deadlock in sem_wait.

3ad3fa962efee12067d68c3405a537dce156a7ac set td-&gt;cancel = 1 to fix
a thread leak when the syscall failed.  The switch to two-way semaphores
cde213f9c3ac1aa168581222edee6a6642113323 allows checking if self-&gt;timer_id
is -1 instead of self-&gt;cancel because timer_delete can't have been called
before the sem_post allows the parent thread to return from timer_create.

The deadlock was observed in a test that called
timer_create(CLOCK_BOOTTIME_ALARM, SIGEV_THREAD, ...) without
CAP_WAKE_ALARM, causing the kernel to return EPERM.

Also disable cancellation around the parent semaphores to avoid
the parent being cancelled while the child is still accessing
the args on the parent stack, and save the result of the timer_create
syscall to return as errno on error.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
sem_wait is a cancellation point.  If the parent thread in timer_create
sets td-&gt;cancel = 1 before the child thread reaches sem_wait then
the thread will exit and sem_post will never be called, causing
the parent thread to deadlock in sem_wait.

3ad3fa962efee12067d68c3405a537dce156a7ac set td-&gt;cancel = 1 to fix
a thread leak when the syscall failed.  The switch to two-way semaphores
cde213f9c3ac1aa168581222edee6a6642113323 allows checking if self-&gt;timer_id
is -1 instead of self-&gt;cancel because timer_delete can't have been called
before the sem_post allows the parent thread to return from timer_create.

The deadlock was observed in a test that called
timer_create(CLOCK_BOOTTIME_ALARM, SIGEV_THREAD, ...) without
CAP_WAKE_ALARM, causing the kernel to return EPERM.

Also disable cancellation around the parent semaphores to avoid
the parent being cancelled while the child is still accessing
the args on the parent stack, and save the result of the timer_create
syscall to return as errno on error.
</pre>
</div>
</content>
</entry>
<entry>
<title>strtod: fix incorrect logic detecting underflow</title>
<updated>2026-10-12T20:26:45+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2026-10-12T20:26:45+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=6426a515e042f32cb9f1d82ec9d0905e0c500d6c'/>
<id>6426a515e042f32cb9f1d82ec9d0905e0c500d6c</id>
<content type='text'>
underflow should be reported (via ERANGE) on any inexact denormal
result, which is expressed in the logic as (denormal &amp;&amp; frac). the
denormal boolean is set above based on the magnitude of the exponent
relative to the target type's exponent range after normalizing the
working mantissa to occupy LDBL_MANT_DIG bits directly above the radix
point. but, since rounding up can raise the exponent out of the
denormal range, there is additional logic to clear the denormal flag
when that happens, and it was wrong.

the logic clearing denormal triggered when:

    bits==LDBL_MANT_DIG+e2-emin

here e2+LDBL_MANT_DIG is the actual place of the highest bit, and
initially, bits+emin was equal to -emax+3. however, at the point the
condition is evaluated, bits no longer represents the full mantissa
width of the target type. it has already been replaced with a reduced
width corresponding to the precision of the denormal. as a consequence
of the replacement, the condition was basically always true (except
when bits gets clamped non-negative), and so the denormal flag got
cleared when rounding up with carry.

the logic is fixed by using the value -emax+3 which is constant for
the duration of the function, and by moving evaluation from before the
exponent adjust to after, since the denormal flag should be cleared
based on the new exponent, not the old exponent.

with this change, behavior has been confirmed to be correct for
rounding both up and down around the minimum normal and maximum
denormal double, expressed both as 21 decimal digits and the full
exact value.

this patch does not address missing underflow logic when parsing hex
floats, which is a separate issue.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
underflow should be reported (via ERANGE) on any inexact denormal
result, which is expressed in the logic as (denormal &amp;&amp; frac). the
denormal boolean is set above based on the magnitude of the exponent
relative to the target type's exponent range after normalizing the
working mantissa to occupy LDBL_MANT_DIG bits directly above the radix
point. but, since rounding up can raise the exponent out of the
denormal range, there is additional logic to clear the denormal flag
when that happens, and it was wrong.

the logic clearing denormal triggered when:

    bits==LDBL_MANT_DIG+e2-emin

here e2+LDBL_MANT_DIG is the actual place of the highest bit, and
initially, bits+emin was equal to -emax+3. however, at the point the
condition is evaluated, bits no longer represents the full mantissa
width of the target type. it has already been replaced with a reduced
width corresponding to the precision of the denormal. as a consequence
of the replacement, the condition was basically always true (except
when bits gets clamped non-negative), and so the denormal flag got
cleared when rounding up with carry.

the logic is fixed by using the value -emax+3 which is constant for
the duration of the function, and by moving evaluation from before the
exponent adjust to after, since the denormal flag should be cleared
based on the new exponent, not the old exponent.

with this change, behavior has been confirmed to be correct for
rounding both up and down around the minimum normal and maximum
denormal double, expressed both as 21 decimal digits and the full
exact value.

this patch does not address missing underflow logic when parsing hex
floats, which is a separate issue.
</pre>
</div>
</content>
</entry>
<entry>
<title>fcntl.h: add new fallocate operation flags</title>
<updated>2026-10-12T15:47:57+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2026-10-12T15:33:00+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=94c40a6175c3114dc3736a3a880f69f776b80a7e'/>
<id>94c40a6175c3114dc3736a3a880f69f776b80a7e</id>
<content type='text'>
these are complete as of linux 7.2
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
these are complete as of linux 7.2
</pre>
</div>
</content>
</entry>
<entry>
<title>swprintf: properly set errno when output is truncated</title>
<updated>2026-10-06T19:13:38+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2026-10-06T19:13:38+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=249a86c1f37314d903227a99e7e07ea45f37c826'/>
<id>249a86c1f37314d903227a99e7e07ea45f37c826</id>
<content type='text'>
unlike snprintf, swprintf is required to discard the computed length
and return -1 if the output does not fit. this was done correctly, but
POSIX also requires errno be set to EOVERFLOW for this condition.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
unlike snprintf, swprintf is required to discard the computed length
and return -1 if the output does not fit. this was done correctly, but
POSIX also requires errno be set to EOVERFLOW for this condition.
</pre>
</div>
</content>
</entry>
<entry>
<title>fnmatch: fix false matches from invalid bytes behaving as end-of-string</title>
<updated>2026-10-06T17:20:05+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2026-10-06T17:20:05+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=be5fd367cff8d5263b5f904067aeb401f93459b9'/>
<id>be5fd367cff8d5263b5f904067aeb401f93459b9</id>
<content type='text'>
when an invalid byte appeared next in the string immediately following
a character that matched the last character of the pattern, it was
mistakenly treated the same as end-of-string, causing fnmatch to
report the string as matching.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
when an invalid byte appeared next in the string immediately following
a character that matched the last character of the pattern, it was
mistakenly treated the same as end-of-string, causing fnmatch to
report the string as matching.
</pre>
</div>
</content>
</entry>
<entry>
<title>fnmatch: do not match reversed ranges in bracket expressions</title>
<updated>2026-10-05T21:49:58+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2026-10-05T21:49:58+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=b1efda5b91735e33635376ca11c9b497a1c66e39'/>
<id>b1efda5b91735e33635376ca11c9b497a1c66e39</id>
<content type='text'>
POSIX allows a reversed-order range to be treated as invalid (forcing
the bracket to be interpreted as a literal) or as valid but not
matching any characters. because we matched the starting character of
the range before identifying it as a range, however, [z-a] would match
'z'.

explicitly check for a subsequent non-terminal '-', and don't match if
one is present. the match, if any, will be caught by the range logic
in the next iteration.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
POSIX allows a reversed-order range to be treated as invalid (forcing
the bracket to be interpreted as a literal) or as valid but not
matching any characters. because we matched the starting character of
the range before identifying it as a range, however, [z-a] would match
'z'.

explicitly check for a subsequent non-terminal '-', and don't match if
one is present. the match, if any, will be caught by the range logic
in the next iteration.
</pre>
</div>
</content>
</entry>
<entry>
<title>fnmatch: fix processing bracket range with multibyte endpoint</title>
<updated>2026-10-05T21:44:14+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2026-10-05T21:44:14+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=cb037c4630ddb87b48ad732bff04ebaa3d42148b'/>
<id>cb037c4630ddb87b48ad732bff04ebaa3d42148b</id>
<content type='text'>
the advancement logic was off-by-one, accounting for the p++ in the
for clause but not the '-' character. this resulted in attempting to
process the last byte of the range endpoint on the next iteration of
the loop.

for a single-byte endpoint this was harmless, but for a multi-byte
character, mbtowc would fail on the next iteration, preventing
matching of any subsequent part of the bracket.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
the advancement logic was off-by-one, accounting for the p++ in the
for clause but not the '-' character. this resulted in attempting to
process the last byte of the range endpoint on the next iteration of
the loop.

for a single-byte endpoint this was harmless, but for a multi-byte
character, mbtowc would fail on the next iteration, preventing
matching of any subsequent part of the bracket.
</pre>
</div>
</content>
</entry>
<entry>
<title>newlocale: fix values for categories not in mask with (locale_t)0 base</title>
<updated>2026-10-02T04:57:48+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2026-10-02T04:52:22+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=9b2d8a1646391d5217f9a358555aebcaab5b8aaf'/>
<id>9b2d8a1646391d5217f9a358555aebcaab5b8aaf</id>
<content type='text'>
the category values from the old locale were only being used for a
non-null base; for null ((locale_t)0) base, a lookup for "" was
wrongly being performed rather than using the C locale values.

this caused, for example, newlocale(LC_CTYPE_MASK,"",0) to produce a
locale_t matching newlocale(LC_ALL_MASK,"",0) rather than one that
only reflects LC_CTYPE.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
the category values from the old locale were only being used for a
non-null base; for null ((locale_t)0) base, a lookup for "" was
wrongly being performed rather than using the C locale values.

this caused, for example, newlocale(LC_CTYPE_MASK,"",0) to produce a
locale_t matching newlocale(LC_ALL_MASK,"",0) rather than one that
only reflects LC_CTYPE.
</pre>
</div>
</content>
</entry>
<entry>
<title>fix off-by-one in wcwidth special cases for tags, variation selectors</title>
<updated>2026-09-30T00:41:33+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2026-09-30T00:41:33+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=1a094684868786b56a8e80c43420b44042ac9204'/>
<id>1a094684868786b56a8e80c43420b44042ac9204</id>
<content type='text'>
these ranges are special-cased because they lie near the top of the
encoding space far above where the bit tables currently end, and they
are unlikely to change often. the last character in each of these
ranges failed to get reported as having width 0.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
these ranges are special-cased because they lie near the top of the
encoding space far above where the bit tables currently end, and they
are unlikely to change often. the last character in each of these
ranges failed to get reported as having width 0.
</pre>
</div>
</content>
</entry>
</feed>
