diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2019-02-14 12:54:34 -0800 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2019-02-19 14:50:31 -0800 |
| commit | 46fd60c70398b51136a2deea84f30e867679ca53 (patch) | |
| tree | d258a055ea443cb8b0b1879a2905af0eb03a3a35 /extmod | |
| parent | 4e75aaecd07ea954aeba5dda59ed3d1b37bfc17d (diff) | |
Prevent infinite display update recursion and fix VFS mounting
Fixes #1529
Diffstat (limited to 'extmod')
| -rw-r--r-- | extmod/vfs_fat_file.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/extmod/vfs_fat_file.c b/extmod/vfs_fat_file.c index 1b2bb27f8..690073ce4 100644 --- a/extmod/vfs_fat_file.c +++ b/extmod/vfs_fat_file.c @@ -186,12 +186,15 @@ STATIC mp_obj_t file_open(fs_user_mount_t *vfs, const mp_obj_type_t *type, mp_ar break; } } + assert(vfs != NULL); + if ((vfs->flags & FSUSER_USB_WRITABLE) != 0 && (mode & FA_WRITE) != 0) { + mp_raise_OSError(MP_EROFS); + } pyb_file_obj_t *o = m_new_obj_with_finaliser(pyb_file_obj_t); o->base.type = type; const char *fname = mp_obj_str_get_str(args[0].u_obj); - assert(vfs != NULL); FRESULT res = f_open(&vfs->fatfs, &o->fp, fname, mode); if (res != FR_OK) { m_del_obj(pyb_file_obj_t, o); |
