diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2018-04-19 15:12:28 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2018-04-19 15:12:28 +0200 |
commit | 391a276ba35216337b777c65fda62561a6e9383f (patch) | |
tree | 201f025951868128fc64c0253589546ca0dea53f /NitrokeyManager.cc | |
parent | 7f5f471d8f3a67fe109e4c8c241de2e1098d275e (diff) | |
parent | 9ab13fd0ae3d85dcb9a3fcef0594aacb1946086b (diff) | |
download | libnitrokey-391a276ba35216337b777c65fda62561a6e9383f.tar.gz libnitrokey-391a276ba35216337b777c65fda62561a6e9383f.tar.bz2 |
Merge branch '110-mixed_strings'
Make sure all C API strings are deallocable.
Tested with Python's 3.6.5 'pytest -sv test_{pro,storage}.py' on Storage v0.50,
Ubuntu 18.04
Closes #110
Diffstat (limited to 'NitrokeyManager.cc')
-rw-r--r-- | NitrokeyManager.cc | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc index 2ca183c..085bf78 100644 --- a/NitrokeyManager.cc +++ b/NitrokeyManager.cc @@ -630,12 +630,12 @@ using nitrokey::misc::strcpyT; auto resp = WriteToTOTPSlot::CommandTransaction::run(device, payload); } - const char * NitrokeyManager::get_totp_slot_name(uint8_t slot_number) { + char * NitrokeyManager::get_totp_slot_name(uint8_t slot_number) { if (!is_valid_totp_slot_number(slot_number)) throw InvalidSlotException(slot_number); slot_number = get_internal_slot_number_for_totp(slot_number); return get_slot_name(slot_number); } - const char * NitrokeyManager::get_hotp_slot_name(uint8_t slot_number) { + char * NitrokeyManager::get_hotp_slot_name(uint8_t slot_number) { if (!is_valid_hotp_slot_number(slot_number)) throw InvalidSlotException(slot_number); slot_number = get_internal_slot_number_for_hotp(slot_number); return get_slot_name(slot_number); @@ -643,7 +643,7 @@ using nitrokey::misc::strcpyT; static const int max_string_field_length = 2*1024; //storage's status string is ~1k - const char * NitrokeyManager::get_slot_name(uint8_t slot_number) { + char * NitrokeyManager::get_slot_name(uint8_t slot_number) { auto payload = get_payload<GetSlotName>(); payload.slot_number = slot_number; auto resp = GetSlotName::CommandTransaction::run(device, payload); @@ -749,7 +749,7 @@ using nitrokey::misc::strcpyT; LockDevice::CommandTransaction::run(device); } - const char *NitrokeyManager::get_password_safe_slot_name(uint8_t slot_number) { + char * NitrokeyManager::get_password_safe_slot_name(uint8_t slot_number) { if (!is_valid_password_safe_slot_number(slot_number)) throw InvalidSlotException(slot_number); auto p = get_payload<GetPasswordSafeSlotName>(); p.slot_number = slot_number; @@ -759,7 +759,7 @@ using nitrokey::misc::strcpyT; bool NitrokeyManager::is_valid_password_safe_slot_number(uint8_t slot_number) const { return slot_number < 16; } - const char *NitrokeyManager::get_password_safe_slot_login(uint8_t slot_number) { + char * NitrokeyManager::get_password_safe_slot_login(uint8_t slot_number) { if (!is_valid_password_safe_slot_number(slot_number)) throw InvalidSlotException(slot_number); auto p = get_payload<GetPasswordSafeSlotLogin>(); p.slot_number = slot_number; @@ -767,7 +767,7 @@ using nitrokey::misc::strcpyT; return strndup((const char *) response.data().slot_login, max_string_field_length); } - const char *NitrokeyManager::get_password_safe_slot_password(uint8_t slot_number) { + char * NitrokeyManager::get_password_safe_slot_password(uint8_t slot_number) { if (!is_valid_password_safe_slot_number(slot_number)) throw InvalidSlotException(slot_number); auto p = get_payload<GetPasswordSafeSlotPassword>(); p.slot_number = slot_number; @@ -1059,7 +1059,7 @@ using nitrokey::misc::strcpyT; stick20::ChangeUpdatePassword::CommandTransaction::run(device, p); } - const char * NitrokeyManager::get_status_storage_as_string(){ + char * NitrokeyManager::get_status_storage_as_string(){ auto p = stick20::GetDeviceStatus::CommandTransaction::run(device); return strndup(p.data().dissect().c_str(), max_string_field_length); } @@ -1069,7 +1069,7 @@ using nitrokey::misc::strcpyT; return p.data(); } - const char * NitrokeyManager::get_SD_usage_data_as_string(){ + char * NitrokeyManager::get_SD_usage_data_as_string(){ auto p = stick20::GetSDCardOccupancy::CommandTransaction::run(device); return strndup(p.data().dissect().c_str(), max_string_field_length); } |