The PMD_INFO_STRING constant string is not guaranteed to appear in the
output binary immediately after an unprintable character. Because of
this, in some cases the information for a driver could be missed by the
PMD info script as it only checks for the prefix at the start of strings
that it finds. Change the script to use "s.find()" rather than
"s.startswith()" to fix this issue.

Fixes: 0ce3cf4afd04 ("usertools/pmdinfo: rewrite simpler script")
Cc: [email protected]

Signed-off-by: Bruce Richardson <[email protected]>
---
 usertools/dpdk-pmdinfo.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/usertools/dpdk-pmdinfo.py b/usertools/dpdk-pmdinfo.py
index 9251c69db9..a4913f2209 100755
--- a/usertools/dpdk-pmdinfo.py
+++ b/usertools/dpdk-pmdinfo.py
@@ -221,8 +221,9 @@ def find_strings(buf: bytes, prefix: str) -> Iterator[str]:
             if b == 0:
                 # end of string
                 s = view[start:i].tobytes().decode("ascii")
-                if s.startswith(prefix):
-                    yield s[len(prefix) :]
+                idx = s.find(prefix)
+                if idx >= 0:
+                    yield s[idx + len(prefix) :]
             # There can be byte sequences where a non-printable byte
             # follows a printable one. Ignore that.
             start = None
-- 
2.51.0

Reply via email to