diff options
author | Simon Glass <sjg@chromium.org> | 2021-11-12 12:28:05 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2022-01-26 08:50:43 -0700 |
commit | 7ae46c35793bcc034f1300d8b79e3fd7e506537c (patch) | |
tree | c82d8c9bb34d430b5099c9b72a6bea7c52c7ae6d /tools/fit_common.c | |
parent | e291a5c9a2acff16ba3b976198bba7da9828c9e9 (diff) |
tools: Avoid leaving extra data at the end of copied files
The copyfile() implementation has strange behaviour if the destination
file already exists. Update it to ensure that any existing data in the
destination file is dropped.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/fit_common.c')
-rw-r--r-- | tools/fit_common.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/fit_common.c b/tools/fit_common.c index 4370de2f61c..5ea43f5fec8 100644 --- a/tools/fit_common.c +++ b/tools/fit_common.c @@ -134,7 +134,7 @@ int copyfile(const char *src, const char *dst) goto out; } - fd_dst = open(dst, O_WRONLY | O_CREAT, 0666); + fd_dst = open(dst, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (fd_dst < 0) { printf("Can't open file %s (%s)\n", dst, strerror(errno)); goto out; |