Commit 5fa4400
committed
tools: rimage: harden CSE header scan and re-sign cleanup
Address review feedback on the verify/re-sign paths:
- cse_header_is_valid() dereferenced the candidate header before
confirming the remaining buffer was large enough, so scanning near the
end of a short or truncated file could read past the allocation. Check
the size first, then inspect the fields. Also include man_v1_5_sue in
the v1.5 verifier set so SUE verify/re-sign scans accept valid headers.
- verify_image() left buffer uninitialised, so an early get_file_size()
failure reached the free(buffer) cleanup with a garbage pointer.
Initialise it to NULL.
- resign_image() left image->out_fd non-NULL when fclose() reported an
error, even though the stream is already closed, leading the caller
cleanup to close the same FILE * twice. Clear the handle before
testing the result.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>1 parent e5c30de commit 5fa4400
1 file changed
Lines changed: 16 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
35 | 38 | | |
36 | 39 | | |
37 | | - | |
38 | | - | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | | - | |
| 43 | + | |
42 | 44 | | |
43 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
44 | 49 | | |
45 | 50 | | |
46 | | - | |
47 | | - | |
| 51 | + | |
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
| |||
1669 | 1673 | | |
1670 | 1674 | | |
1671 | 1675 | | |
1672 | | - | |
| 1676 | + | |
1673 | 1677 | | |
1674 | 1678 | | |
1675 | 1679 | | |
| |||
1842 | 1846 | | |
1843 | 1847 | | |
1844 | 1848 | | |
1845 | | - | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
1846 | 1855 | | |
1847 | 1856 | | |
1848 | 1857 | | |
1849 | | - | |
1850 | 1858 | | |
1851 | 1859 | | |
1852 | 1860 | | |
| |||
0 commit comments