diff options
| author | Mingjie Shen <shen497@purdue.edu> | 2023-04-20 18:20:37 -0400 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2023-05-19 22:01:10 +1000 |
| commit | a9fc0343f08287ba3cb51c231507583770ae5dfe (patch) | |
| tree | ff31aafdc4aea16d63bc9a7688507fd74d315bb3 | |
| parent | 978829fcd6a6cae2a004fc1425f968c3b6a093c7 (diff) | |
extmod/vfs_lfsx: Fix offset used before range check.
Use of offset 'from' should follow the range check.
Signed-off-by: Mingjie Shen <shen497@purdue.edu>
| -rw-r--r-- | extmod/vfs_lfsx.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/extmod/vfs_lfsx.c b/extmod/vfs_lfsx.c index de1f42197..fe0731ece 100644 --- a/extmod/vfs_lfsx.c +++ b/extmod/vfs_lfsx.c @@ -323,7 +323,7 @@ STATIC mp_obj_t MP_VFS_LFSx(chdir)(mp_obj_t self_in, mp_obj_t path_in) { size_t from = 1; char *cwd = vstr_str(&self->cur_dir); while (from < CWD_LEN) { - for (; cwd[from] == '/' && from < CWD_LEN; ++from) { + for (; from < CWD_LEN && cwd[from] == '/'; ++from) { // Scan for the start } if (from > to) { @@ -331,7 +331,7 @@ STATIC mp_obj_t MP_VFS_LFSx(chdir)(mp_obj_t self_in, mp_obj_t path_in) { vstr_cut_out_bytes(&self->cur_dir, to, from - to); from = to; } - for (; cwd[from] != '/' && from < CWD_LEN; ++from) { + for (; from < CWD_LEN && cwd[from] != '/'; ++from) { // Scan for the next / } if ((from - to) == 1 && cwd[to] == '.') { |
