-
Notifications
You must be signed in to change notification settings - Fork 939
Open
Milestone
Description
set_size should zero-fill new data region after extending data region. Interestingly this one only fails when --net is provided as then we use another implementation for the filesystem
#include <assert.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <wasi/api_wasi.h>
int main(void) {
int fd = open("fd_filestat_set_size_data", O_CREAT | O_TRUNC | O_RDWR, 0644);
write(fd, "aaaaa", 5);
__wasi_fd_filestat_set_size(fd, 0);
// BUG: set_size should zero-fill new data region after extending data region.
// Repro requires --net because it selects the overlay/COW filesystem path.
__wasi_fd_filestat_set_size(fd, 5);
lseek(fd, 0, SEEK_SET);
char zeros[5];
read(fd, zeros, sizeof(zeros));
if (zeros[0] != 0 || zeros[1] != 0 || zeros[2] != 0 || zeros[3] != 0 || zeros[4] != 0) {
printf("Unexpected data: %02x %02x %02x %02x %02x\n",
(unsigned char)zeros[0],
(unsigned char)zeros[1],
(unsigned char)zeros[2],
(unsigned char)zeros[3],
(unsigned char)zeros[4]);
exit(1);
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels