Update cmdhf14b.c to respect bytes order when evaluating SR/ST25TB locks

Signed-off-by: Benjamin DELPY <benjamin@gentilkiwi.com>
This commit is contained in:
Benjamin DELPY 2025-03-25 13:59:10 +01:00 committed by GitHub
commit ee1a38d975
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -569,7 +569,7 @@ static const char *get_st_lock_info(uint8_t model, const uint8_t *lockbytes, uin
default: default:
return ST_LOCK_INFO_EMPTY; return ST_LOCK_INFO_EMPTY;
} }
if ((lockbytes[1] & mask) == 0) { if ((lockbytes[3] & mask) == 0) {
return _RED_("1"); return _RED_("1");
} }
return ST_LOCK_INFO_EMPTY; return ST_LOCK_INFO_EMPTY;
@ -578,7 +578,7 @@ static const char *get_st_lock_info(uint8_t model, const uint8_t *lockbytes, uin
case 0x6: // SRI512 case 0x6: // SRI512
case 0xC: { // SRT512 case 0xC: { // SRT512
//need data[2] and data[3] //need data[2] and data[3]
uint8_t b = 1; uint8_t b = 2;
switch (blk) { switch (blk) {
case 0: case 0:
mask = 0x01; mask = 0x01;
@ -606,35 +606,35 @@ static const char *get_st_lock_info(uint8_t model, const uint8_t *lockbytes, uin
break; break;
case 8: case 8:
mask = 0x01; mask = 0x01;
b = 0; b = 3;
break; break;
case 9: case 9:
mask = 0x02; mask = 0x02;
b = 0; b = 3;
break; break;
case 10: case 10:
mask = 0x04; mask = 0x04;
b = 0; b = 3;
break; break;
case 11: case 11:
mask = 0x08; mask = 0x08;
b = 0; b = 3;
break; break;
case 12: case 12:
mask = 0x10; mask = 0x10;
b = 0; b = 3;
break; break;
case 13: case 13:
mask = 0x20; mask = 0x20;
b = 0; b = 3;
break; break;
case 14: case 14:
mask = 0x40; mask = 0x40;
b = 0; b = 3;
break; break;
case 15: case 15:
mask = 0x80; mask = 0x80;
b = 0; b = 3;
break; break;
} }
if ((lockbytes[b] & mask) == 0) { if ((lockbytes[b] & mask) == 0) {
@ -679,7 +679,7 @@ static const char *get_st_lock_info(uint8_t model, const uint8_t *lockbytes, uin
break; break;
} }
// iceman: this is opposite! need sample to test with. // iceman: this is opposite! need sample to test with.
if ((lockbytes[0] & mask)) { if ((lockbytes[2] & mask)) {
return _RED_("1"); return _RED_("1");
} }
return ST_LOCK_INFO_EMPTY; return ST_LOCK_INFO_EMPTY;