Merge pull request #2458 from jmichelp/master

Fix out-of-bound reading in parity
This commit is contained in:
Iceman 2024-08-20 13:41:34 +02:00 committed by GitHub
commit 28c1f60900
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -53,12 +53,12 @@ Card Number 11111111111111111111 = 0FFFFF
//E E E E E |E E E E E |EO O O O O| O O O O O| O //E E E E E |E E E E E |EO O O O O| O O O O O| O
set_bit_by_position(packed, set_bit_by_position(packed,
evenparity32( evenparity32(
get_nonlinear_field(packed, 16, (uint8_t[]) {2, 4, 6, 8, 10, 12, 14, 16, 18, 20})) get_nonlinear_field(packed, 10, (uint8_t[]) {2, 4, 6, 8, 10, 12, 14, 16, 18, 20}))
, 0); , 0);
set_bit_by_position(packed, set_bit_by_position(packed,
oddparity32( oddparity32(
get_nonlinear_field(packed, 16, (uint8_t[]) {21, 23, 25, 27, 29, 31, 33, 35, 37, 39})) get_nonlinear_field(packed, 10, (uint8_t[]) {21, 23, 25, 27, 29, 31, 33, 35, 37, 39}))
, 41); , 41);
if (preamble) if (preamble)
return add_HID_header(packed); return add_HID_header(packed);
@ -76,9 +76,9 @@ static bool Unpack_Defcon32(wiegand_message_t *packed, wiegand_card_t *card) {
card->ParityValid = card->ParityValid =
(get_bit_by_position(packed, 41) == oddparity32( (get_bit_by_position(packed, 41) == oddparity32(
get_nonlinear_field(packed, 16, (uint8_t[]) {21, 23, 25, 27, 29, 31, 33, 35, 37, 39})))&& get_nonlinear_field(packed, 10, (uint8_t[]) {21, 23, 25, 27, 29, 31, 33, 35, 37, 39})))&&
(get_bit_by_position(packed, 0) == (get_bit_by_position(packed, 0) ==
evenparity32(get_nonlinear_field(packed, 16, (uint8_t[]) {2, 4, 6, 8, 10, 12, 14, 16, 18, 20}))); evenparity32(get_nonlinear_field(packed, 10, (uint8_t[]) {2, 4, 6, 8, 10, 12, 14, 16, 18, 20})));
return true; return true;
} }