mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:37:43 +00:00
DHCPClient: Parse MacAddress parts using StringUtils
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.
This commit is contained in:
parent
863bc35399
commit
47fa8d83bb
1 changed files with 4 additions and 2 deletions
|
@ -29,6 +29,7 @@
|
|||
#include <AK/JsonArray.h>
|
||||
#include <AK/JsonObject.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringUtils.h>
|
||||
#include <AK/Types.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/File.h>
|
||||
|
@ -39,8 +40,9 @@
|
|||
|
||||
static u8 mac_part(const Vector<String>& parts, size_t index)
|
||||
{
|
||||
auto chars = parts.at(index).characters();
|
||||
return (chars[0] - '0') * 16 + (chars[1] - '0');
|
||||
auto result = AK::StringUtils::convert_to_uint_from_hex(parts.at(index));
|
||||
VERIFY(result.has_value());
|
||||
return result.value();
|
||||
}
|
||||
|
||||
static MACAddress mac_from_string(const String& str)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue