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:
parent
fcf663b560
commit
b3dc6529eb
1 changed files with 1 additions and 1 deletions
2
image.c
2
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->addr = image->size;
|
||||||
image->data_dir_sigtable->size = len + padlen;
|
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) {
|
if (fd < 0) {
|
||||||
perror("open");
|
perror("open");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in a new issue