Skip to content

Commit 130768c

Browse files
casaroliPatrickRobbIOL
authored andcommitted
fix(sample_container): truncate file (#100)
If there is already a file in the filesystem with the same name and it is larger than the new size we are writing, the file size will not be truncated and we will end up with junk after the end of the wasm buffer. Use FS_O_TRUNC, so that the file will always be truncated to the new size. Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
1 parent 90b0a83 commit 130768c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/samples-mini/zephyr/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void create_sample_container(char *file_name) {
8787
int res;
8888

8989
fs_file_t_init(&f);
90-
res = fs_open(&f, file_path, FS_O_CREATE | FS_O_RDWR);
90+
res = fs_open(&f, file_path, FS_O_CREATE | FS_O_TRUNC | FS_O_RDWR);
9191

9292
fs_write(&f, &wasm_binary, wasm_binary_len);
9393
fs_close(&f);

0 commit comments

Comments
 (0)