mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-11-10 17:49:32 +08:00
lfops fcAll: avoid division by zero
This commit is contained in:
parent
d9308d912d
commit
091ddb26f0
1 changed files with 15 additions and 13 deletions
|
@ -730,8 +730,6 @@ static void fcAll(uint8_t fc, int *n, uint8_t clock, uint16_t *modCnt) {
|
|||
uint8_t halfFC = fc >> 1;
|
||||
uint8_t wavesPerClock = clock / fc;
|
||||
uint8_t mod = clock % fc; //modifier
|
||||
uint8_t modAdj = fc / mod; //how often to apply modifier
|
||||
bool modAdjOk = !(fc % mod); //if (fc % mod==0) modAdjOk = true;
|
||||
|
||||
// loop through clock - step field clock
|
||||
for (uint8_t idx = 0; idx < wavesPerClock; idx++) {
|
||||
|
@ -740,19 +738,23 @@ static void fcAll(uint8_t fc, int *n, uint8_t clock, uint16_t *modCnt) {
|
|||
memset(dest + (*n) + (fc - halfFC), 1, halfFC);
|
||||
*n += fc;
|
||||
}
|
||||
if (mod > 0)(*modCnt)++;
|
||||
if (mod > 0) {
|
||||
uint8_t modAdj = fc / mod; //how often to apply modifier
|
||||
bool modAdjOk = !(fc % mod); //if (fc % mod==0) modAdjOk = true;
|
||||
(*modCnt)++;
|
||||
|
||||
if ((mod > 0) && modAdjOk) { //fsk2
|
||||
if ((*modCnt % modAdj) == 0) { //if 4th 8 length wave in a rf/50 add extra 8 length wave
|
||||
memset(dest + (*n), 0, fc - halfFC);
|
||||
memset(dest + (*n) + (fc - halfFC), 1, halfFC);
|
||||
*n += fc;
|
||||
if (modAdjOk) { //fsk2
|
||||
if ((*modCnt % modAdj) == 0) { //if 4th 8 length wave in a rf/50 add extra 8 length wave
|
||||
memset(dest + (*n), 0, fc - halfFC);
|
||||
memset(dest + (*n) + (fc - halfFC), 1, halfFC);
|
||||
*n += fc;
|
||||
}
|
||||
}
|
||||
if (!modAdjOk) { //fsk1
|
||||
memset(dest + (*n), 0, mod - (mod >> 1));
|
||||
memset(dest + (*n) + (mod - (mod >> 1)), 1, mod >> 1);
|
||||
*n += mod;
|
||||
}
|
||||
}
|
||||
if (mod > 0 && !modAdjOk) { //fsk1
|
||||
memset(dest + (*n), 0, mod - (mod >> 1));
|
||||
memset(dest + (*n) + (mod - (mod >> 1)), 1, mod >> 1);
|
||||
*n += mod;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue