mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:37:34 +00:00
LibEDID: Return "Unknown" string if failed to determine the manufacturer
Before of this patch, It happened that the return string could be "@@@", as a result of doing mathematical addition of ASCII '@' with bits when decoding the packed manufacturer ID bytes from the EDID. To avoid this, consider m_legacy_manufacturer_id to be invalid until we successfully decode the packed bytes.
This commit is contained in:
parent
20c9e4c05c
commit
1a641f9af7
2 changed files with 6 additions and 0 deletions
|
@ -332,10 +332,13 @@ ErrorOr<void> Parser::parse()
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 packed_id = read_be(&raw_edid().vendor.manufacturer_id);
|
u16 packed_id = read_be(&raw_edid().vendor.manufacturer_id);
|
||||||
|
if (packed_id == 0x0)
|
||||||
|
return {};
|
||||||
m_legacy_manufacturer_id[0] = (char)((u16)'A' + ((packed_id >> 10) & 0x1f) - 1);
|
m_legacy_manufacturer_id[0] = (char)((u16)'A' + ((packed_id >> 10) & 0x1f) - 1);
|
||||||
m_legacy_manufacturer_id[1] = (char)((u16)'A' + ((packed_id >> 5) & 0x1f) - 1);
|
m_legacy_manufacturer_id[1] = (char)((u16)'A' + ((packed_id >> 5) & 0x1f) - 1);
|
||||||
m_legacy_manufacturer_id[2] = (char)((u16)'A' + (packed_id & 0x1f) - 1);
|
m_legacy_manufacturer_id[2] = (char)((u16)'A' + (packed_id & 0x1f) - 1);
|
||||||
m_legacy_manufacturer_id[3] = '\0';
|
m_legacy_manufacturer_id[3] = '\0';
|
||||||
|
m_legacy_manufacturer_id_valid = true;
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -420,6 +423,8 @@ StringView Parser::legacy_manufacturer_id() const
|
||||||
#ifndef KERNEL
|
#ifndef KERNEL
|
||||||
String Parser::manufacturer_name() const
|
String Parser::manufacturer_name() const
|
||||||
{
|
{
|
||||||
|
if (!m_legacy_manufacturer_id_valid)
|
||||||
|
return "Unknown";
|
||||||
auto manufacturer_id = legacy_manufacturer_id();
|
auto manufacturer_id = legacy_manufacturer_id();
|
||||||
# ifdef ENABLE_PNP_IDS_DATA
|
# ifdef ENABLE_PNP_IDS_DATA
|
||||||
if (auto pnp_id_data = PnpIDs::find_by_manufacturer_id(manufacturer_id); pnp_id_data.has_value())
|
if (auto pnp_id_data = PnpIDs::find_by_manufacturer_id(manufacturer_id); pnp_id_data.has_value())
|
||||||
|
|
|
@ -457,6 +457,7 @@ private:
|
||||||
String m_version;
|
String m_version;
|
||||||
#endif
|
#endif
|
||||||
char m_legacy_manufacturer_id[4] {};
|
char m_legacy_manufacturer_id[4] {};
|
||||||
|
bool m_legacy_manufacturer_id_valid { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue