mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 02:27:26 -07:00
CodeQL fixes for "Comparison between A of type TypeA and B of wider type TypeB"
This commit is contained in:
parent
20c4756f2a
commit
91be146ecb
6 changed files with 36 additions and 3 deletions
|
@ -296,6 +296,7 @@ typedef struct spiffs_t {
|
||||||
// file system configuration
|
// file system configuration
|
||||||
spiffs_config cfg;
|
spiffs_config cfg;
|
||||||
// number of logical blocks
|
// number of logical blocks
|
||||||
|
// BUGBUG -- Should this be of type spiffs_block_ix?
|
||||||
u32_t block_count;
|
u32_t block_count;
|
||||||
|
|
||||||
// cursor for free blocks, block index
|
// cursor for free blocks, block index
|
||||||
|
|
|
@ -536,6 +536,13 @@ static s32_t spiffs_page_consistency_check_i(spiffs *fs) {
|
||||||
s32_t res = SPIFFS_OK;
|
s32_t res = SPIFFS_OK;
|
||||||
spiffs_page_ix pix_offset = 0;
|
spiffs_page_ix pix_offset = 0;
|
||||||
|
|
||||||
|
// this _should_ never happen, but prefer to see debug message / error
|
||||||
|
// rather than silently entering infinite loop.
|
||||||
|
if (fs->block_count > ((spiffs_block_ix)(-1))) {
|
||||||
|
SPIFFS_DBG("Avoiding infinite loop, block_count "_SPIPRIbl" too large for spiffs_block_ix type\n", fs->block_count);
|
||||||
|
SPIFFS_API_CHECK_RES(fs, SPIFFS_ERR_INTERNAL);
|
||||||
|
}
|
||||||
|
|
||||||
// for each range of pages fitting into work memory
|
// for each range of pages fitting into work memory
|
||||||
while (pix_offset < SPIFFS_PAGES_PER_BLOCK(fs) * fs->block_count) {
|
while (pix_offset < SPIFFS_PAGES_PER_BLOCK(fs) * fs->block_count) {
|
||||||
// set this flag to abort all checks and rescan the page range
|
// set this flag to abort all checks and rescan the page range
|
||||||
|
|
|
@ -52,6 +52,13 @@ s32_t SPIFFS_format(spiffs *fs) {
|
||||||
|
|
||||||
SPIFFS_LOCK(fs);
|
SPIFFS_LOCK(fs);
|
||||||
|
|
||||||
|
// this _should_ never happen, but prefer to see debug message / error
|
||||||
|
// rather than silently entering infinite loop.
|
||||||
|
if (fs->block_count > ((spiffs_block_ix)(-1))) {
|
||||||
|
SPIFFS_DBG("Avoiding infinite loop, block_count "_SPIPRIbl" too large for spiffs_block_ix type\n", fs->block_count);
|
||||||
|
SPIFFS_API_CHECK_RES_UNLOCK(fs, SPIFFS_ERR_INTERNAL);
|
||||||
|
}
|
||||||
|
|
||||||
spiffs_block_ix bix = 0;
|
spiffs_block_ix bix = 0;
|
||||||
while (bix < fs->block_count) {
|
while (bix < fs->block_count) {
|
||||||
fs->max_erase_count = 0;
|
fs->max_erase_count = 0;
|
||||||
|
|
|
@ -364,6 +364,7 @@ static s32_t spiffs_obj_lu_scan_v(
|
||||||
// Checks magic if enabled
|
// Checks magic if enabled
|
||||||
s32_t spiffs_obj_lu_scan(
|
s32_t spiffs_obj_lu_scan(
|
||||||
spiffs *fs) {
|
spiffs *fs) {
|
||||||
|
|
||||||
s32_t res;
|
s32_t res;
|
||||||
spiffs_block_ix bix;
|
spiffs_block_ix bix;
|
||||||
int entry;
|
int entry;
|
||||||
|
@ -371,6 +372,14 @@ s32_t spiffs_obj_lu_scan(
|
||||||
spiffs_block_ix unerased_bix = (spiffs_block_ix) - 1;
|
spiffs_block_ix unerased_bix = (spiffs_block_ix) - 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// this _should_ never happen, but prefer to see debug message / error
|
||||||
|
// rather than silently entering infinite loop.
|
||||||
|
if (fs->block_count > ((spiffs_block_ix)(-1))) {
|
||||||
|
SPIFFS_DBG("Avoiding infinite loop, block_count "_SPIPRIbl" too large for spiffs_block_ix type\n", fs->block_count);
|
||||||
|
SPIFFS_API_CHECK_RES(fs, SPIFFS_ERR_INTERNAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// find out erase count
|
// find out erase count
|
||||||
// if enabled, check magic
|
// if enabled, check magic
|
||||||
bix = 0;
|
bix = 0;
|
||||||
|
|
|
@ -115,7 +115,7 @@ static int EmSendCmdThinfilmRaw(const uint8_t *resp, uint16_t respLen) {
|
||||||
|
|
||||||
// Ensure that the FPGA Delay Queue is empty
|
// Ensure that the FPGA Delay Queue is empty
|
||||||
uint8_t fpga_queued_bits = FpgaSendQueueDelay >> 3;
|
uint8_t fpga_queued_bits = FpgaSendQueueDelay >> 3;
|
||||||
for (i = 0; i <= (fpga_queued_bits >> 3) + 1;) {
|
for (i = 0; i <= fpga_queued_bits / 8u + 1u;) {
|
||||||
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
|
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
|
||||||
AT91C_BASE_SSC->SSC_THR = SEC_F;
|
AT91C_BASE_SSC->SSC_THR = SEC_F;
|
||||||
FpgaSendQueueDelay = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
FpgaSendQueueDelay = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
||||||
|
|
|
@ -3226,13 +3226,22 @@ int CmdHF14ANdefRead(const char *Cmd) {
|
||||||
return PM3_EOVFLOW;
|
return PM3_EOVFLOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint16_t i = offset; i < ndef_size + offset; i += max_rapdu_size) {
|
for (size_t i = offset; i < ndef_size + offset; i += max_rapdu_size) {
|
||||||
uint16_t segment_size = max_rapdu_size < ndef_size + offset - i ? max_rapdu_size : ndef_size + offset - i;
|
size_t segment_size = max_rapdu_size < ndef_size + offset - i ? max_rapdu_size : ndef_size + offset - i;
|
||||||
|
|
||||||
keep_field_on = i < ndef_size + offset - max_rapdu_size;
|
keep_field_on = i < ndef_size + offset - max_rapdu_size;
|
||||||
aREAD_NDEF_n = 0;
|
aREAD_NDEF_n = 0;
|
||||||
param_gethex_to_eol("00b00000", 0, aREAD_NDEF, sizeof(aREAD_NDEF), &aREAD_NDEF_n);
|
param_gethex_to_eol("00b00000", 0, aREAD_NDEF, sizeof(aREAD_NDEF), &aREAD_NDEF_n);
|
||||||
aREAD_NDEF[2] = i >> 8;
|
aREAD_NDEF[2] = i >> 8;
|
||||||
aREAD_NDEF[3] = i & 0xFF;
|
aREAD_NDEF[3] = i & 0xFF;
|
||||||
|
|
||||||
|
// BUGBUG -- segment_size is stuffed into a single-byte field below?
|
||||||
|
if (segment_size > 0xFFu) {
|
||||||
|
PrintAndLogEx(ERR, "Segment size too large (0x%zx > 0xFF)", segment_size);
|
||||||
|
DropField();
|
||||||
|
free(ndef_file);
|
||||||
|
return PM3_EOVFLOW;
|
||||||
|
}
|
||||||
aREAD_NDEF[4] = segment_size;
|
aREAD_NDEF[4] = segment_size;
|
||||||
|
|
||||||
res = ExchangeAPDU14a(aREAD_NDEF, aREAD_NDEF_n + 1, activate_field, keep_field_on, response, sizeof(response), &resplen);
|
res = ExchangeAPDU14a(aREAD_NDEF, aREAD_NDEF_n + 1, activate_field, keep_field_on, response, sizeof(response), &resplen);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue