From 46fd60c70398b51136a2deea84f30e867679ca53 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 14 Feb 2019 12:54:34 -0800 Subject: Prevent infinite display update recursion and fix VFS mounting Fixes #1529 --- extmod/vfs_fat_file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'extmod') 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); -- cgit v1.2.3