[HAL] Fix parser bugs in HalpDebugPciDumpBus (#1895)

- Match subclass properly, don't match third subclass.
- Don't match subclass from next class, add ClassEnd boundary.
- Use class name if subclass name not available.
- Gracefully return "Unknown" if no class name found.
This commit is contained in:
Stanislav Motylkov 2019-09-24 00:46:23 +03:00 committed by Hermès BÉLUSCA - MAÏTO
parent 43f03da358
commit 894635bb00

View file

@ -809,7 +809,7 @@ HalpDebugPciDumpBus(IN ULONG i,
IN ULONG k, IN ULONG k,
IN PPCI_COMMON_CONFIG PciData) IN PPCI_COMMON_CONFIG PciData)
{ {
PCHAR p, ClassName, SubClassName, VendorName, ProductName, SubVendorName; PCHAR p, ClassName, ClassEnd, SubClassName, VendorName, ProductName, SubVendorName;
ULONG Length; ULONG Length;
CHAR LookupString[16] = ""; CHAR LookupString[16] = "";
CHAR bSubClassName[64] = ""; CHAR bSubClassName[64] = "";
@ -824,19 +824,28 @@ HalpDebugPciDumpBus(IN ULONG i,
if (ClassName) if (ClassName)
{ {
/* Isolate the subclass name */ /* Isolate the subclass name */
ClassName += 6; ClassName += strlen("C 00 ");
sprintf(LookupString, "\t%02x ", PciData->SubClass); ClassEnd = strstr(ClassName, "\nC ");
sprintf(LookupString, "\n\t%02x ", PciData->SubClass);
SubClassName = strstr(ClassName, LookupString); SubClassName = strstr(ClassName, LookupString);
if (SubClassName) if (ClassEnd && SubClassName > ClassEnd)
{ {
/* Copy the subclass into our buffer */ SubClassName = NULL;
SubClassName += 5;
p = strpbrk(SubClassName, "\r\n");
Length = p - SubClassName;
if (Length >= sizeof(bSubClassName)) Length = sizeof(bSubClassName) - 1;
strncpy(bSubClassName, SubClassName, Length);
bSubClassName[Length] = '\0';
} }
if (!SubClassName)
{
SubClassName = ClassName;
}
else
{
SubClassName += strlen("\n\t00 ");
}
/* Copy the subclass into our buffer */
p = strpbrk(SubClassName, "\r\n");
Length = p - SubClassName;
if (Length >= sizeof(bSubClassName)) Length = sizeof(bSubClassName) - 1;
strncpy(bSubClassName, SubClassName, Length);
bSubClassName[Length] = '\0';
} }
/* Isolate the vendor name */ /* Isolate the vendor name */