From 24359ea0744a26df6e7466b7b3ade0ee1aa369ac Mon Sep 17 00:00:00 2001 From: Ondrej Mikle Date: Wed, 28 Aug 2019 15:56:19 +0200 Subject: [PATCH] core/modtrezorio: use upstream's fix of read-after-buffer --- core/embed/extmod/modtrezorio/ff.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/embed/extmod/modtrezorio/ff.c b/core/embed/extmod/modtrezorio/ff.c index 6fcf53aa3..3c9c615e9 100644 --- a/core/embed/extmod/modtrezorio/ff.c +++ b/core/embed/extmod/modtrezorio/ff.c @@ -1663,9 +1663,14 @@ static FRESULT create_name ( /* FR_OK: successful, FR_INVALID_NAME: could not if (di >= FF_MAX_LFN) return FR_INVALID_NAME; /* Reject too long name */ lfn[di++] = wc; /* Store the Unicode character */ } - while (*p == '/' || *p == '\\') p++; /* Skip duplicated separators if exist */ - *path = p; /* Return pointer to the next segment */ - cf = (wc < ' ') ? NS_LAST : 0; /* Set last segment flag if end of the path */ + + if (wc < ' ') { /* End of path? */ + cf = NS_LAST; /* Set last segment flag */ + } else { + cf = 0; /* Next segment follows */ + while (*p == '/' || *p == '\\') p++; /* Skip duplicated separators if exist */ + } + *path = p; /* Return pointer to the next segment */ while (di) { /* Snip off trailing spaces and dots if exist */ wc = lfn[di - 1];