mirror of
https://github.com/micropython/micropython.git
synced 2026-01-06 12:10:13 +01:00
extmod/vfs: Support larger integer range in VFS stat time fields.
On ports like unix where the Epoch is 1970/1/1 and atime/mtime/ctime are in seconds since the Epoch, this value will overflow a small-int on 32-bit systems. So far this is only an issue on 32-bit unix builds that use the VFS layer (eg dev and coverage unix variants) but the fix (using mp_obj_new_int_from_uint instead of MP_OBJ_NEW_SMALL_INT) is there for all ports so as to not complicate the code, and because they will need the range one day. Also apply a similar fix to other fields in VfsPosix.stat because they may also be large. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -326,9 +326,9 @@ STATIC mp_obj_t fat_vfs_stat(mp_obj_t vfs_in, mp_obj_t path_in) {
|
||||
t->items[4] = MP_OBJ_NEW_SMALL_INT(0); // st_uid
|
||||
t->items[5] = MP_OBJ_NEW_SMALL_INT(0); // st_gid
|
||||
t->items[6] = mp_obj_new_int_from_uint(fno.fsize); // st_size
|
||||
t->items[7] = MP_OBJ_NEW_SMALL_INT(seconds); // st_atime
|
||||
t->items[8] = MP_OBJ_NEW_SMALL_INT(seconds); // st_mtime
|
||||
t->items[9] = MP_OBJ_NEW_SMALL_INT(seconds); // st_ctime
|
||||
t->items[7] = mp_obj_new_int_from_uint(seconds); // st_atime
|
||||
t->items[8] = mp_obj_new_int_from_uint(seconds); // st_mtime
|
||||
t->items[9] = mp_obj_new_int_from_uint(seconds); // st_ctime
|
||||
|
||||
return MP_OBJ_FROM_PTR(t);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user