diff --git a/applets/pass/pass.c b/applets/pass/pass.c index a6d88417..8845c409 100644 --- a/applets/pass/pass.c +++ b/applets/pass/pass.c @@ -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; } @@ -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; diff --git a/interfaces/USB/class/kbdhid/kbdhid.c b/interfaces/USB/class/kbdhid/kbdhid.c index 4b040959..ba39ac46 100644 --- a/interfaces/USB/class/kbdhid/kbdhid.c +++ b/interfaces/USB/class/kbdhid/kbdhid.c @@ -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; // " @@ -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;