https://git.reactos.org/?p=reactos.git;a=commitdiff;h=894635bb001f0d20612ac…
commit 894635bb001f0d20612ac38b1a7e5ec9a210674c
Author: Stanislav Motylkov <x86corez(a)gmail.com>
AuthorDate: Tue Sep 24 00:46:23 2019 +0300
Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org>
CommitDate: Mon Sep 23 23:46:23 2019 +0200
[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.
---
hal/halx86/legacy/bussupp.c | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/hal/halx86/legacy/bussupp.c b/hal/halx86/legacy/bussupp.c
index b8a7cb888d9..aad25838f55 100644
--- a/hal/halx86/legacy/bussupp.c
+++ b/hal/halx86/legacy/bussupp.c
@@ -809,7 +809,7 @@ HalpDebugPciDumpBus(IN ULONG i,
IN ULONG k,
IN PPCI_COMMON_CONFIG PciData)
{
- PCHAR p, ClassName, SubClassName, VendorName, ProductName, SubVendorName;
+ PCHAR p, ClassName, ClassEnd, SubClassName, VendorName, ProductName, SubVendorName;
ULONG Length;
CHAR LookupString[16] = "";
CHAR bSubClassName[64] = "";
@@ -824,19 +824,28 @@ HalpDebugPciDumpBus(IN ULONG i,
if (ClassName)
{
/* Isolate the subclass name */
- ClassName += 6;
- sprintf(LookupString, "\t%02x ", PciData->SubClass);
+ ClassName += strlen("C 00 ");
+ ClassEnd = strstr(ClassName, "\nC ");
+ sprintf(LookupString, "\n\t%02x ", PciData->SubClass);
SubClassName = strstr(ClassName, LookupString);
- if (SubClassName)
+ if (ClassEnd && SubClassName > ClassEnd)
{
- /* Copy the subclass into our buffer */
- 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';
+ SubClassName = NULL;
}
+ 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 */