sanitizer_common: fix up onprint.cpp test more

D112630 ("sanitizer_common: fix up onprint.cpp test")
added O_CREAT, but we also need O_TRUNC b/c the file
may not exist, or may exist as well.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D112788
This commit is contained in:
Dmitry Vyukov 2021-10-29 10:17:18 +02:00
parent b42d51ba9a
commit a871c34e8d
1 changed files with 1 additions and 1 deletions

View File

@ -26,7 +26,7 @@ __sanitizer_on_print(const char *str) {
int main(int argc, char *argv[]) {
assert(argc >= 2);
f = open(argv[1], O_CREAT | O_WRONLY, 0666);
f = open(argv[1], O_CREAT | O_TRUNC | O_WRONLY, 0666);
// Use-after-free to trigger ASan/TSan reports.
void *ptr = malloc(1);