From fb1c7276413e10fa89e6bf34c5aacd4794d910ee Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 10 Aug 2024 21:59:03 +0800 Subject: [PATCH] GPU (Linux): ensure we correctly get the marketing name --- src/detection/gpu/gpu_pci.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/detection/gpu/gpu_pci.c b/src/detection/gpu/gpu_pci.c index b865d8af9..de81f9b60 100644 --- a/src/detection/gpu/gpu_pci.c +++ b/src/detection/gpu/gpu_pci.c @@ -44,17 +44,17 @@ void ffGPUParsePciIds(FFstrbuf* content, uint8_t subclass, uint16_t vendor, uint if (!end) end = content->chars + content->length; - char* openingBracket = memchr(start, '[', (uint32_t) (end - start)); - if (openingBracket) + char* closingBracket = end - 1; + if (*closingBracket == ']') { - openingBracket++; - char* closingBracket = memchr(openingBracket, ']', (uint32_t) (end - openingBracket)); - if (closingBracket) + char* openingBracket = memrchr(start, '[', (size_t) (closingBracket - start)); + if (openingBracket) { + openingBracket++; ffStrbufSetNS(&gpu->name, (uint32_t) (closingBracket - openingBracket), openingBracket); if (coreName) { - ffStrbufSetNS(coreName, (uint32_t) (closingBracket - openingBracket), start); + ffStrbufSetNS(coreName, (uint32_t) (openingBracket - start) - 1, start); ffStrbufTrimRight(coreName, ' '); } }