Commit ec2aa32
committed
Fix crash in cpuid_riscv64.c
The crash is reproducible when building OpenBLAS without forcing a
target in a riscv64 container running on an X86_64 machine with an
older version of QEMU, e.g., 7.0.0, registered with binfmt_misc to
run riscv64 binaries. With this setup, cat /proc/cpuinfo in the
container returns the cpu information for the host, which contains a
"model name" string, and we execute the buggy code. The code in
question is searching in an uninitialised buffer for the ':' character
and doesn't check to see whether it was found or not. This can result
in pmodel containing the pointer value 1 and a crash when pmodel is
defererenced. The algorithm to detect the C910V CPU has not been
modified, merely fixed to prevent the crash.
A few additional checks for NULL pointers are added to improve the
robustness of the code and a whitespace error is corrected.1 parent d6a5174 commit ec2aa32
1 file changed
Lines changed: 10 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
92 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
93 | 97 | | |
94 | 98 | | |
95 | 99 | | |
96 | 100 | | |
97 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
98 | 104 | | |
99 | 105 | | |
100 | 106 | | |
101 | 107 | | |
102 | 108 | | |
103 | | - | |
| 109 | + | |
104 | 110 | | |
105 | | - | |
| 111 | + | |
106 | 112 | | |
107 | 113 | | |
108 | 114 | | |
| |||
0 commit comments