Having an alias function that only wraps another one is silly, and
keeping the more obvious name should flush out more uses of deprecated
strings.
No behavior change.
This is a first step towards handling OOM errors instead of just
crashing the program.
Now UDPServer's method `receive()` return memory allocation
errors explicitly with help of ErrorOr.
This removes one FIXME and make a bunch of new ones. :(
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.
One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
Otherwise, we end up propagating those dependencies into targets that
link against that library, which creates unnecessary link-time
dependencies.
Also included are changes to readd now missing dependencies to tools
that actually need them.
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.
Error::from_string_literal now takes direct char const*s, while
Error::from_string_view does what Error::from_string_literal used to do:
taking StringViews. This change will remove the need to insert `sv`
after error strings when returning string literal errors once
StringView(char const*) is removed.
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).
Resetting the interface just based on the fact that it already has an IP
assigned doesn't make much sense, considering that we frequently end up
here after having configured an interface via DHCP already.
Instead, just keep the part that prevents us from sending DHCP
discoveries to interfaces that shouldn't be using DHCP.
While we are at it, place some of the logging behind a debug flag, as
this function is apparently meant to be run frequently.
This partially reverts commit e14d4482a1.
Now, the caller needs to give interface names in command-line arguments.
The DHCPClient will perform DHCP discovery only on these adapters. The
service now immediately closes when no interfaces were given.
We don't check if interface has already IP address assigned; we just
reset it to zero so that DHCP resolution will not fail.
The compiler would complain about `__builtin_memcpy` in ByteBuffer::copy
writing out of bounds, as it isn't able to deduce the invariant that the
inline buffer is only used when the requested size is smaller than the
inline capacity.
The other change is more bizarre. If the destructor's declaration
exists, gcc complains about a `delete` operation causing an
out-of-bounds array access.
error: array subscript 'DHCPv4Client::__as_base [0]' is partly outside
array bounds of 'unsigned char [8]' [-Werror=array-bounds]
14 | ~DHCPv4Client() = default;
| ^
This looks like a compiler bug, and I'll report it if I find a suitable
reduced reproducer.
Also add slightly richer parse errors now that we can include a string
literal with returned errors.
This will allow us to use TRY() when working with JSON data.
Derivatives of Core::Object should be constructed through
ClassName::construct(), to avoid handling ref-counted objects with
refcount zero. Fixing the visibility means that misuses like this are
more difficult.
Just casting a void* to a T* and dereferencing it is not particularly
safe. Also UBSAN was complaining. Use memcpy into a default constructed
T instead and require that the T be trivially copyable.
Previously we'd only only send one DHCP request for network interfaces
which were up when DHCPClient started. If that packet was lost we'd
never send another request for those interfaces.
Also, if an interface were to appear after DHCPClient started (not
that that is possible at the moment) we wouldn't send requests for
that interface either.
Since applications using Core::EventLoop no longer need to create a
socket in /tmp/rpc/, and also don't need to listen for incoming
connections on this socket, we can remove a whole bunch of pledges!
We had some inconsistencies before:
- Sometimes "The", sometimes "the"
- Sometimes trailing ".", sometimes no trailing "."
I picked the most common one (lowecase "the", trailing ".") and applied
it to all copyright headers.
By using the exact same string everywhere we can ensure nothing gets
missed during a global search (and replace), and that these
inconsistencies are not spread any further (as copyright headers are
commonly copied to new files).
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 *
Calling memcpy with null pointers results in undefined behaviour, even
if count is zero.
This in turns is exploited by GCC. For example, the following code:
memcpy (dst, src, n);
if (!src)
return;
src[0] = 0xcafe;
will be optimized as:
memcpy (dst, src, n);
src[0] = 0xcafe;
IOW the test for NULL is gone.
Attempts are spaced out with exponential backoff, cut at 10 minutes per
attempt.
Also avoid trying to acquire an IP on interfaces that aren't up.
Fixes#6126.
Fixes#6125.
Real DHCP servers might decide to send the DHCPAck directly to the
specified ciaddr instead of as a unicast or multicast, resulting in
the ack being ignored by the network adapter when we are requesting
a new IPv4 address instead of renewing an existing lease, as the
yiaddr (and as a result the ciaddr) is set to the offered address in
that case instead of the current ip address.
Some real DHCP servers dont set the siaddr field in the DHCPOffer to
their IPv4 (and instead leave it blank - 0.0.0.0), which results in
the server assuming the DHCPRequest is not directed at him when it
has the ServerIdentifier option attached that specifies 0.0.0.0 as
the targeted server. So instead we just omit the option and let the
DHCP servers decipher the target themselves based on the requested IP.
The current parsing code assumed the ascii lowercase letters came after
the ascii numbers, which is not the case, and as such corrupted any mac
address that included hex letters (a-f). We likely did not notice this
as QEMU's emulated MAC is made up of only hex digits.