When parsing /proc/cpuinfo, ghw uses strings.Split(line, ":") to separate key : value and directly takes parts[1] as the value.
If the value itself contains a colon (:), everything after the first colon in the value is ignored, resulting in truncated fields.
This issue can be reliably reproduced on Hygon CPUs.
Environment:
CPU: Hygon C86-4G
OS: Linux
ghw: 0.21.2
Reproduction example:
Excerpt from /proc/cpuinfo:
model name : Hygon C86-4G (OPN:7470)
Current ghw parsing result:
model name = "Hygon C86-4G (OPN"
Expected result:
model name = "Hygon C86-4G (OPN:7470)"
Root cause:
The relevant code:
|
parts := strings.Split(line, ":") |
When the value contains a colon (e.g., OPN:7470), strings.Split produces multiple elements, but ghw only uses parts[1], discarding the remainder.
Notes:
This is a general parsing bug, not a vendor-specific exception.
When parsing /proc/cpuinfo, ghw uses strings.Split(line, ":") to separate key : value and directly takes parts[1] as the value.
If the value itself contains a colon (:), everything after the first colon in the value is ignored, resulting in truncated fields.
This issue can be reliably reproduced on Hygon CPUs.
Environment:
CPU: Hygon C86-4G
OS: Linux
ghw: 0.21.2
Reproduction example:
Excerpt from /proc/cpuinfo:
model name : Hygon C86-4G (OPN:7470)
Current ghw parsing result:
model name = "Hygon C86-4G (OPN"
Expected result:
model name = "Hygon C86-4G (OPN:7470)"
Root cause:
The relevant code:
ghw/pkg/cpu/cpu_linux.go
Line 378 in 50f6054
When the value contains a colon (e.g., OPN:7470), strings.Split produces multiple elements, but ghw only uses parts[1], discarding the remainder.
Notes:
This is a general parsing bug, not a vendor-specific exception.