-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CodeQL -- Actual fixes #2720
base: master
Are you sure you want to change the base?
CodeQL -- Actual fixes #2720
Changes from all commits
4d67f56
20c4756
91be146
1c75690
18f6604
1c3f845
0531946
99e8de3
6613ff7
dc0e6f4
715e876
1e95dad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ name: "CodeQL" | |
|
||
on: | ||
workflow_dispatch: | ||
|
||
push: | ||
branches: [ master ] | ||
pull_request: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,8 +52,16 @@ s32_t SPIFFS_format(spiffs *fs) { | |
|
||
SPIFFS_LOCK(fs); | ||
|
||
uint32_t block_count = fs->block_count; | ||
// this _should_ never happen, but prefer to see debug message / error | ||
// rather than silently entering infinite loop. | ||
if (block_count > ((spiffs_block_ix)(-1))) { | ||
SPIFFS_DBG("Avoiding infinite loop, block_count "_SPIPRIbl" too large for spiffs_block_ix type\n", block_count); | ||
SPIFFS_API_CHECK_RES_UNLOCK(fs, SPIFFS_ERR_INTERNAL); | ||
} | ||
|
||
spiffs_block_ix bix = 0; | ||
while (bix < fs->block_count) { | ||
while (bix < block_count) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it really that block_count is large, or ? not sure how this would be a infinite loop? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just another location where spiffs's choice to not use type The original issue is, of course, that Anyways, by moving Does that make more sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. aha, so erase_block takes u16... rgr that. yeah, make everything u16? Thanks, excellent explanation btw |
||
fs->max_erase_count = 0; | ||
s32_t res = spiffs_erase_block(fs, bix); | ||
if (res != SPIFFS_OK) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please have second set of eyes review these checks.