This decoded every character twice: utf8_encoded_valid_unichar() decodes internally to do its validation and then throws the codepoint away, and the caller immediately called utf8_encoded_to_unichar() again to get the very same codepoint back. Fix that where it originates rather than at the call site: add utf8_encoded_valid_unichar_full(), which optionally returns the character it had to decode anyway, and make utf8_encoded_valid_unichar() a wrapper that passes NULL. Callers that want both the validity and the value now decode once. On top of that add a bulk fast path, since almost everything we are asked about is plain printable ASCII: test eight bytes at a time for that, i.e. that no byte is >= 0x80, none is < 0x20 and none is 0x7f. A remainder of less than eight bytes is copied into a word padded with spaces so that it can be tested the same way. A word that does not qualify falls through to the per character path, so tabs, newlines and multibyte sequences are handled exactly as before. The function sits on journalctl's per-field output path, so this is measurable: on a 730M journal spread over 100 files, journalctl -o export goes from 4.02s to about 2.9s. Also extend the tests, which so far covered neither DEL nor the C1 range nor allow_newline=false: place each of the interesting bytes at each offset within the eight byte word, and check a multibyte character straddling the end of one. The new code was verified to agree with the old one on 41945090 inputs, for both values of allow_newline: every byte string of length zero to three over all 256 byte values, four million random strings over uniform bytes, over an ASCII-heavy alphabet and over an alphabet of encoding boundary bytes, and a corpus placing every byte value at every offset of buffers of every length from eight to twenty-four bytes, with valid and truncated multibyte sequences straddling the word boundary.
System and Service Manager
Details
Most documentation is available on systemd's website.
Assorted, older, general information about systemd can be found in the systemd Wiki.
Information about build requirements is provided in the README file.
Consult our NEWS file for information about what's new in the most recent systemd versions.
Please see the Code Map for information about this repository's layout and content.
Please see the Hacking guide for information on how to hack on systemd and test your modifications.
Please see our Contribution Guidelines for more information about filing GitHub Issues and posting GitHub Pull Requests.
When preparing patches for systemd, please follow our Coding Style Guidelines.
If you are looking for support, please contact our mailing list, join our IRC channel #systemd on libera.chat or Matrix channel
Stable branches with backported patches are available in the stable repo.
We have a security bug bounty program sponsored by the Sovereign Tech Fund hosted on YesWeHack
Repositories with distribution packages built from git main are available on OBS, and also repositories with packages built from the latest stable release
