mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
[HAL] Fix more bugs in HalpDebugPciDumpBus (#1939)
- Don't match device id outside current vendor id list.
- Don't match subsystem id outside current device id list.
- Refactor some magic constants.
Addendum to 894635b
.
This commit is contained in:
parent
6ec38aa942
commit
07706eca3a
1 changed files with 29 additions and 7 deletions
|
@ -809,10 +809,10 @@ HalpDebugPciDumpBus(IN ULONG i,
|
|||
IN ULONG k,
|
||||
IN PPCI_COMMON_CONFIG PciData)
|
||||
{
|
||||
PCHAR p, ClassName, ClassEnd, SubClassName, VendorName, ProductName, SubVendorName;
|
||||
PCHAR p, ClassName, Boundary, SubClassName, VendorName, ProductName, SubVendorName;
|
||||
ULONG Length;
|
||||
CHAR LookupString[16] = "";
|
||||
CHAR bSubClassName[64] = "";
|
||||
CHAR bSubClassName[64] = "Unknown";
|
||||
CHAR bVendorName[64] = "";
|
||||
CHAR bProductName[128] = "Unknown device";
|
||||
CHAR bSubVendorName[128] = "Unknown";
|
||||
|
@ -825,10 +825,10 @@ HalpDebugPciDumpBus(IN ULONG i,
|
|||
{
|
||||
/* Isolate the subclass name */
|
||||
ClassName += strlen("C 00 ");
|
||||
ClassEnd = strstr(ClassName, "\nC ");
|
||||
Boundary = strstr(ClassName, "\nC ");
|
||||
sprintf(LookupString, "\n\t%02x ", PciData->SubClass);
|
||||
SubClassName = strstr(ClassName, LookupString);
|
||||
if (ClassEnd && SubClassName > ClassEnd)
|
||||
if (Boundary && SubClassName > Boundary)
|
||||
{
|
||||
SubClassName = NULL;
|
||||
}
|
||||
|
@ -854,25 +854,43 @@ HalpDebugPciDumpBus(IN ULONG i,
|
|||
if (VendorName)
|
||||
{
|
||||
/* Copy the vendor name into our buffer */
|
||||
VendorName += 8;
|
||||
VendorName += strlen("\r\n0000 ");
|
||||
p = strpbrk(VendorName, "\r\n");
|
||||
Length = p - VendorName;
|
||||
if (Length >= sizeof(bVendorName)) Length = sizeof(bVendorName) - 1;
|
||||
strncpy(bVendorName, VendorName, Length);
|
||||
bVendorName[Length] = '\0';
|
||||
p += strlen("\r\n");
|
||||
while (*p == '\t' || *p == '#')
|
||||
{
|
||||
p = strpbrk(p, "\r\n");
|
||||
p += strlen("\r\n");
|
||||
}
|
||||
Boundary = p;
|
||||
|
||||
/* Isolate the product name */
|
||||
sprintf(LookupString, "\t%04x ", PciData->DeviceID);
|
||||
ProductName = strstr(VendorName, LookupString);
|
||||
if (Boundary && ProductName >= Boundary)
|
||||
{
|
||||
ProductName = NULL;
|
||||
}
|
||||
if (ProductName)
|
||||
{
|
||||
/* Copy the product name into our buffer */
|
||||
ProductName += 7;
|
||||
ProductName += strlen("\t0000 ");
|
||||
p = strpbrk(ProductName, "\r\n");
|
||||
Length = p - ProductName;
|
||||
if (Length >= sizeof(bProductName)) Length = sizeof(bProductName) - 1;
|
||||
strncpy(bProductName, ProductName, Length);
|
||||
bProductName[Length] = '\0';
|
||||
p += strlen("\r\n");
|
||||
while ((*p == '\t' && *(p + 1) == '\t') || *p == '#')
|
||||
{
|
||||
p = strpbrk(p, "\r\n");
|
||||
p += strlen("\r\n");
|
||||
}
|
||||
Boundary = p;
|
||||
|
||||
/* Isolate the subvendor and subsystem name */
|
||||
sprintf(LookupString,
|
||||
|
@ -880,10 +898,14 @@ HalpDebugPciDumpBus(IN ULONG i,
|
|||
PciData->u.type0.SubVendorID,
|
||||
PciData->u.type0.SubSystemID);
|
||||
SubVendorName = strstr(ProductName, LookupString);
|
||||
if (Boundary && SubVendorName >= Boundary)
|
||||
{
|
||||
SubVendorName = NULL;
|
||||
}
|
||||
if (SubVendorName)
|
||||
{
|
||||
/* Copy the subvendor name into our buffer */
|
||||
SubVendorName += 13;
|
||||
SubVendorName += strlen("\t\t0000 0000 ");
|
||||
p = strpbrk(SubVendorName, "\r\n");
|
||||
Length = p - SubVendorName;
|
||||
if (Length >= sizeof(bSubVendorName)) Length = sizeof(bSubVendorName) - 1;
|
||||
|
|
Loading…
Reference in a new issue