Commit 218f57c
committed
tools: ctl: bound csv data write against abi header size
The ascii csv branch of read_setup() advances the write index past the
32-byte abi header for -r (no_abi) input but still bounds each write with
n < n_max, while the binary branch stops at n_max - abi_size. A csv tuning
file with ctrl_size/4 values then writes sizeof(struct sof_abi_hdr) bytes
past the end of the tlv buffer.
ctrl_size is not guaranteed to be a multiple of sizeof(uint32_t) either,
so bounding the byte count alone still lets the final 4-byte store run up
to 3 bytes past the buffer. Count the csv values and stop after the last
whole uint32_t that fits in the data area, which also keeps the loop from
mixing a size in bytes with an index into a uint32_t array.
Signed-off-by: Syed Mohammed Nayyar <jmestwa@gmail.com>1 parent 6f1170c commit 218f57c
1 file changed
Lines changed: 11 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
| 125 | + | |
125 | 126 | | |
126 | 127 | | |
127 | 128 | | |
| |||
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
147 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
148 | 152 | | |
149 | | - | |
150 | | - | |
| 153 | + | |
| 154 | + | |
151 | 155 | | |
152 | | - | |
| 156 | + | |
153 | 157 | | |
154 | 158 | | |
155 | 159 | | |
156 | 160 | | |
157 | 161 | | |
158 | 162 | | |
159 | | - | |
160 | | - | |
| 163 | + | |
161 | 164 | | |
162 | 165 | | |
| 166 | + | |
163 | 167 | | |
164 | 168 | | |
165 | 169 | | |
| |||
0 commit comments