mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
mem leak out of bounds
This commit is contained in:
parent
491adacb94
commit
26f7f07120
1 changed files with 20 additions and 12 deletions
|
@ -143,12 +143,10 @@ static inline void clear_bitarray24(uint32_t *bitarray) {
|
|||
memset(bitarray, 0x00, sizeof(uint32_t) * (1 << 19));
|
||||
}
|
||||
|
||||
|
||||
static inline void set_bitarray24(uint32_t *bitarray) {
|
||||
memset(bitarray, 0xff, sizeof(uint32_t) * (1 << 19));
|
||||
}
|
||||
|
||||
|
||||
static inline void set_bit24(uint32_t *bitarray, uint32_t index) {
|
||||
bitarray[index >> 5] |= 0x80000000 >> (index & 0x0000001f);
|
||||
}
|
||||
|
@ -157,36 +155,46 @@ static inline uint32_t test_bit24(uint32_t *bitarray, uint32_t index) {
|
|||
return bitarray[index >> 5] & (0x80000000 >> (index & 0x0000001f));
|
||||
}
|
||||
|
||||
|
||||
static inline uint32_t next_state(uint32_t *bitarray, uint32_t state) {
|
||||
if (++state == 1 << 24) return 1 << 24;
|
||||
if (++state == (1 << 24)) {
|
||||
return (1 << 24);
|
||||
}
|
||||
|
||||
uint32_t index = state >> 5;
|
||||
uint_fast8_t bit = state & 0x1f;
|
||||
uint_fast8_t bit = state & 0x1F;
|
||||
uint32_t line = bitarray[index] << bit;
|
||||
while (bit <= 0x1f) {
|
||||
if (line & 0x80000000) return state;
|
||||
|
||||
while (bit <= 0x1F) {
|
||||
if (line & 0x80000000) {
|
||||
return state;
|
||||
}
|
||||
state++;
|
||||
bit++;
|
||||
line <<= 1;
|
||||
}
|
||||
index++;
|
||||
while (bitarray[index] == 0x00000000 && state < 1 << 24) {
|
||||
while (state < (1 << 24) && bitarray[index] == 0x00000000 ) {
|
||||
index++;
|
||||
state += 0x20;
|
||||
}
|
||||
if (state >= 1 << 24) return 1 << 24;
|
||||
|
||||
if (state >= (1 << 24)) {
|
||||
return (1 << 24);
|
||||
}
|
||||
#if defined __GNUC__
|
||||
return state + __builtin_clz(bitarray[index]);
|
||||
#else
|
||||
bit = 0x00;
|
||||
line = bitarray[index];
|
||||
while (bit <= 0x1f) {
|
||||
if (line & 0x80000000) return state;
|
||||
while (bit <= 0x1F) {
|
||||
if (line & 0x80000000) {
|
||||
return state;
|
||||
}
|
||||
state++;
|
||||
bit++;
|
||||
line <<= 1;
|
||||
}
|
||||
return 1 << 24;
|
||||
return (1 << 24);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue