Commit 263fe3b
committed
anonymize-fdt: allocate every temporary file with mktemp
The awk report was named by appending `.report` to the mktemp name of the
cleaned dts, and created by shell redirection. mktemp guarantees the name
it returns, not one derived from it: the temporary directory is shared
and world-writable, so the derived name is predictable from the moment
the first file appears, and anyone on the host could pre-create it as a
symlink that `2>` then writes through — an arbitrary file write as the
invoking user. Give the report its own mktemp, and check all three calls
for failure.
A cleanup trap on EXIT, INT, TERM and HUP replaces the end-of-loop rm, so
a dtc failure part-way through a file no longer leaves the temporaries
behind under `set -e`. The names are cleared after each iteration so the
trap only removes what is live, and cleanup tests them with `if` rather
than `[ -n ... ] && rm`, whose non-zero status would abandon the removals
after an unset name.1 parent 4773ce0 commit 263fe3b
1 file changed
Lines changed: 26 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
38 | 57 | | |
39 | 58 | | |
40 | 59 | | |
41 | 60 | | |
42 | 61 | | |
43 | 62 | | |
44 | | - | |
45 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
46 | 66 | | |
47 | 67 | | |
48 | 68 | | |
49 | 69 | | |
50 | 70 | | |
51 | | - | |
52 | 71 | | |
53 | 72 | | |
54 | 73 | | |
| |||
72 | 91 | | |
73 | 92 | | |
74 | 93 | | |
75 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
76 | 98 | | |
0 commit comments