Disallow writes to readonly file
This commit is contained in:
parent
1ed8746541
commit
5843870c1d
@ -1526,6 +1526,11 @@ static errval_t _fat32_fwrite(struct fat32 *fat32, struct fat32_handle *file_han
|
||||
err = fat32_read_directory_entry(fat32, file_handle->directory_entry_ref, &directory_entry);
|
||||
if (err_is_fail(err)) return err;
|
||||
|
||||
// check if the directory entry is readonly
|
||||
if (directory_entry.attributes & FAT32_ATTR_READ_ONLY) {
|
||||
return FS_ERR_WRITE;
|
||||
}
|
||||
|
||||
// if the current position in the file is past the end we need to increase the file size accordingly
|
||||
if (file_handle->byte_offset >= directory_entry.file_size || file_handle->current_cluster == 0) {
|
||||
// debug_printf("Invalid current cluster %u, updating it: %u (%lu)\n", file_handle->current_cluster, file_handle->first_cluster, file_handle->byte_offset);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user