Skip to content

Commit

Permalink
fix init error and length error
Browse files Browse the repository at this point in the history
  • Loading branch information
dangfan committed Jan 1, 2024
1 parent 38314bb commit 53049cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
11 changes: 5 additions & 6 deletions applets/pass/pass.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ int pass_install(const uint8_t reset) {
}

memzero(slots, sizeof(slots));
if (write_file(PASS_FILE, slots, 0, 0, 1) < 0) return -1;
if (write_file(PASS_FILE, slots, 0, sizeof(slots), 1) < 0) return -1;

return 0;
}
Expand Down Expand Up @@ -91,14 +91,13 @@ int pass_write_config(const CAPDU *capdu, RAPDU *rapdu) {
break;

case PASS_SLOT_STATIC:
if (index + sizeof(slots[0].password) + sizeof(slots[0].with_enter) > LC ||
slots[i].password[0] > PASS_MAX_PASSWORD_LENGTH) {
// Not enough data for PASS_SLOT_STATIC or password is too long
if (DATA[index] > PASS_MAX_PASSWORD_LENGTH) {
// Password is too long
EXCEPT(SW_WRONG_DATA);
}
slots[i].type = type;
memcpy(slots[i].password, &DATA[index], DATA[index]);
index += DATA[index];
memcpy(slots[i].password, &DATA[index], DATA[index] + 1);
index += DATA[index] + 1;
slots[i].with_enter = DATA[index++];
break;

Expand Down
3 changes: 2 additions & 1 deletion interfaces/USB/class/kbdhid/kbdhid.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ static uint8_t ascii2keycode(char ch) {
return 4 + ch - 'A';

switch(ch) {
case 13: return 0x28; // \r
case 32: return 0x2C; // space
case 33: return 0x1E; // !
case 34: return 0x34; // "
Expand Down Expand Up @@ -107,7 +108,7 @@ uint8_t KBDHID_Loop(void) {
if (touch != TOUCH_NO) {
const int len = pass_handle_touch(touch, key_sequence);
if (len <= 0) {
DBG_MSG("HID: do nothing\n");
DBG_MSG("Do nothing\n");
return 0;
}
key_sequence[len] = 0;
Expand Down

0 comments on commit 53049cb

Please sign in to comment.