Commit e6be8ea
committed
fix(anonymizer): truncate output files on open to prevent stale JSON
When running the anonymizer tool multiple times pointing to the same
output paths, the files were opened with O_CREATE|O_WRONLY but without
O_TRUNC. This means any previous content is kept in place and new data
is written on top. If the new output happens to be shorter than the old
one, the leftover bytes at the end produce malformed JSON that cannot
be parsed.
Added os.O_TRUNC to all three os.OpenFile calls across writer.go and
extractor.go so the file is always zeroed out before writing begins.
Fixes: #8231
Signed-off-by: Sakthi Harish <sakthi.harish@edgeverve.com>1 parent e75b845 commit e6be8ea
2 files changed
+3
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
0 commit comments