image: open output file with O_TRUNC

Prevents weirdness when overwriting old files.

Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
This commit is contained in:
Jeremy Kerr 2012-05-12 09:44:17 -07:00
parent fcf663b560
commit b3dc6529eb

View file

@ -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;