https://git.reactos.org/?p=reactos.git;a=commitdiff;h=07706eca3a4d94f5902f7…
commit 07706eca3a4d94f5902f71e38212f936ffcd724d
Author: Stanislav Motylkov <x86corez(a)gmail.com>
AuthorDate: Sat Sep 28 19:30:56 2019 +0300
Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org>
CommitDate: Sat Sep 28 18:30:56 2019 +0200
[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.
---
hal/halx86/legacy/bussupp.c | 36 +++++++++++++++++++++++++++++-------
1 file changed, 29 insertions(+), 7 deletions(-)
diff --git a/hal/halx86/legacy/bussupp.c b/hal/halx86/legacy/bussupp.c
index aad25838f55..ba44b4cec91 100644
--- a/hal/halx86/legacy/bussupp.c
+++ b/hal/halx86/legacy/bussupp.c
@@ -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;