Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).
No functional changes.
This commit moves the length calculations out to be directly on the
StringView users. This is an important step towards the goal of removing
StringView(char const*), as it moves the responsibility of calculating
the size of the string to the user of the StringView (which will prevent
naive uses causing OOB access).
glibc before 2.28 defines major() and minor() macros from sys/types.h.
This triggers a Lagom warning for old distros that use versions older
than that, such as Ubuntu 18.04. This fixes a break in the
compiler-explorer Lagom build, which is based off 18.04 docker
containers.
Since 8209c2b570 was added the requires
check for copy_characters_to_buffer matched StringViews as well, which
caused unexpected null bytes to be inserted for non null-terminated
fields.
Benefits:
- Braced-initialization prevents unknown narrowing conversions.
- Using designated initializers will result in a compiler error when a
member is skipped or forgotten.
Problem:
- `memset` is used to initialize data instead of using default
initialization.
Solution:
- Default initialize all member variables.
- Eliminate use of `memset` in favor of C++ braced initialization.
Problem:
- The getters and setters duplicate code for conversions.
- Getters are returning `const StringView` rather than non-`const`.
Solution:
- Factor out common code to helper functions.
- Return `StringView` as non-`const`.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.
See: https://spdx.dev/resources/use/#identifiers
This was done with the `ambr` search and replace tool.
ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
Since the central directory offset in the end of central directory
record and the local file offset in each central directory header
are user-controlled arbitary data, we have to bounds check them
before using them.
We now also check we have enough space in the incoming buffer for the
various signatures and optional (length specified) fields. This helps
prevents a possible heap overflow read.