guid: Add handling of mixed endianness GUIDs
This commit is contained in:
parent
042a377e35
commit
cae6298dce
BIN
limine-pxe.bin
BIN
limine-pxe.bin
Binary file not shown.
BIN
limine.bin
BIN
limine.bin
Binary file not shown.
BIN
stage2.map
BIN
stage2.map
Binary file not shown.
@ -24,7 +24,6 @@ bool is_valid_guid(const char *s) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
static void guid_convert_le_cluster(uint8_t *dest, const char *s, int len) {
|
||||
size_t p = 0;
|
||||
for (int i = len - 1; i >= 0; i--) {
|
||||
@ -33,7 +32,6 @@ static void guid_convert_le_cluster(uint8_t *dest, const char *s, int len) {
|
||||
i % 2 ? (dest[p] = val) : (dest[p++] |= val << 4);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
static void guid_convert_be_cluster(uint8_t *dest, const char *s, int len) {
|
||||
size_t p = 0;
|
||||
@ -44,7 +42,7 @@ static void guid_convert_be_cluster(uint8_t *dest, const char *s, int len) {
|
||||
}
|
||||
}
|
||||
|
||||
bool string_to_guid(struct guid *guid, const char *s) {
|
||||
bool string_to_guid_be(struct guid *guid, const char *s) {
|
||||
if (!is_valid_guid(s))
|
||||
return false;
|
||||
|
||||
@ -56,3 +54,16 @@ bool string_to_guid(struct guid *guid, const char *s) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool string_to_guid_mixed(struct guid *guid, const char *s) {
|
||||
if (!is_valid_guid(s))
|
||||
return false;
|
||||
|
||||
guid_convert_le_cluster((uint8_t *)guid + 0, s + 0, 8);
|
||||
guid_convert_le_cluster((uint8_t *)guid + 4, s + 9, 4);
|
||||
guid_convert_le_cluster((uint8_t *)guid + 6, s + 14, 4);
|
||||
guid_convert_be_cluster((uint8_t *)guid + 8, s + 19, 4);
|
||||
guid_convert_be_cluster((uint8_t *)guid + 10, s + 24, 12);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ struct guid {
|
||||
} __attribute__((packed));
|
||||
|
||||
bool is_valid_guid(const char *s);
|
||||
bool string_to_guid(struct guid *guid, const char *s);
|
||||
bool string_to_guid_be(struct guid *guid, const char *s);
|
||||
bool string_to_guid_mixed(struct guid *guid, const char *s);
|
||||
|
||||
#endif
|
||||
|
@ -109,12 +109,17 @@ static bool uri_bios_dispatch(struct file_handle *fd, char *loc, char *path) {
|
||||
|
||||
static bool uri_guid_dispatch(struct file_handle *fd, char *guid_str, char *path) {
|
||||
struct guid guid;
|
||||
if (!string_to_guid(&guid, guid_str))
|
||||
if (!string_to_guid_be(&guid, guid_str))
|
||||
return false;
|
||||
|
||||
struct part part;
|
||||
if (!part_get_by_guid(&part, &guid))
|
||||
return false;
|
||||
if (!part_get_by_guid(&part, &guid)) {
|
||||
if (!string_to_guid_mixed(&guid, guid_str))
|
||||
return false;
|
||||
|
||||
if (!part_get_by_guid(&part, &guid))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fopen(fd, &part, path))
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user