From b3dc6529eb4ffae0b148b769f49e6993f1024640 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Sat, 12 May 2012 09:44:17 -0700 Subject: image: open output file with O_TRUNC Prevents weirdness when overwriting old files. Signed-off-by: Jeremy Kerr --- image.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/image.c b/image.c index cfafbb0..418883e 100644 --- a/image.c +++ b/image.c @@ -351,7 +351,7 @@ int image_write_signed(struct image *image, const char *filename) image->data_dir_sigtable->addr = image->size; image->data_dir_sigtable->size = len + padlen; - fd = open(filename, O_WRONLY | O_CREAT, 0644); + fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd < 0) { perror("open"); return -1; -- cgit 1.2.3-korg