mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-04-02 18:39:57 +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 halfFC = fc >> 1;
|
||||||
uint8_t wavesPerClock = clock / fc;
|
uint8_t wavesPerClock = clock / fc;
|
||||||
uint8_t mod = clock % fc; //modifier
|
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
|
// loop through clock - step field clock
|
||||||
for (uint8_t idx = 0; idx < wavesPerClock; idx++) {
|
for (uint8_t idx = 0; idx < wavesPerClock; idx++) {
|
||||||
|
@ -740,20 +738,24 @@ static void fcAll(uint8_t fc, int *n, uint8_t clock, uint16_t *modCnt) {
|
||||||
memset(dest + (*n) + (fc - halfFC), 1, halfFC);
|
memset(dest + (*n) + (fc - halfFC), 1, halfFC);
|
||||||
*n += fc;
|
*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 (modAdjOk) { //fsk2
|
||||||
if ((*modCnt % modAdj) == 0) { //if 4th 8 length wave in a rf/50 add extra 8 length wave
|
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), 0, fc - halfFC);
|
||||||
memset(dest + (*n) + (fc - halfFC), 1, halfFC);
|
memset(dest + (*n) + (fc - halfFC), 1, halfFC);
|
||||||
*n += fc;
|
*n += fc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mod > 0 && !modAdjOk) { //fsk1
|
if (!modAdjOk) { //fsk1
|
||||||
memset(dest + (*n), 0, mod - (mod >> 1));
|
memset(dest + (*n), 0, mod - (mod >> 1));
|
||||||
memset(dest + (*n) + (mod - (mod >> 1)), 1, mod >> 1);
|
memset(dest + (*n) + (mod - (mod >> 1)), 1, mod >> 1);
|
||||||
*n += mod;
|
*n += mod;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepare a waveform pattern in the buffer based on the ID given then
|
// prepare a waveform pattern in the buffer based on the ID given then
|
||||||
|
|
Loading…
Add table
Reference in a new issue