aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NitrokeyManager.cc25
-rw-r--r--include/device_proto.h2
-rw-r--r--include/misc.h9
3 files changed, 10 insertions, 26 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc
index 096a8c4..9a9d106 100644
--- a/NitrokeyManager.cc
+++ b/NitrokeyManager.cc
@@ -26,30 +26,7 @@ char * strndup(const char* str, size_t maxlen){
#endif
-
- /**
- * Copies string from pointer to fixed size C-style array. Src needs to be a valid C-string - eg. ended with '\0'.
- * Throws when source is bigger than destination.
- * @tparam T type of destination array
- * @param dest fixed size destination array
- * @param src pointer to source c-style valid string
- */
- template <typename T>
- void strcpyT(T& dest, const char* src){
-
- if (src == nullptr)
-// throw EmptySourceStringException(slot_number);
- return;
- const size_t s_dest = sizeof dest;
- LOG(std::string("strcpyT sizes dest src ")
- +std::to_string(s_dest)+ " "
- +std::to_string(strlen(src))+ " "
- ,nitrokey::log::Loglevel::DEBUG_L2);
- if (strlen(src) > s_dest){
- throw TooLongStringException(strlen(src), s_dest, src);
- }
- strncpy((char*) &dest, src, s_dest);
- }
+using nitrokey::misc::strcpyT;
template <typename T>
typename T::CommandPayload get_payload(){
diff --git a/include/device_proto.h b/include/device_proto.h
index ad2dbae..0d355ce 100644
--- a/include/device_proto.h
+++ b/include/device_proto.h
@@ -362,7 +362,7 @@ namespace nitrokey {
LOG("Incoming HID packet:", Loglevel::DEBUG);
LOG(static_cast<std::string>(resp), Loglevel::DEBUG);
LOG(std::string("receiving_retry_counter count: ") + std::to_string(receiving_retry_counter),
- Loglevel::DEBUG);
+ Loglevel::DEBUG_L2);
if (resp.device_status == static_cast<uint8_t>(stick10::device_status::busy) &&
static_cast<stick20::device_status>(resp.storage_status.device_status)
diff --git a/include/misc.h b/include/misc.h
index 111d772..176b77c 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -21,6 +21,13 @@ namespace misc {
return oss.str();
}
+ /**
+ * Copies string from pointer to fixed size C-style array. Src needs to be a valid C-string - eg. ended with '\0'.
+ * Throws when source is bigger than destination.
+ * @tparam T type of destination array
+ * @param dest fixed size destination array
+ * @param src pointer to source c-style valid string
+ */
template <typename T>
void strcpyT(T& dest, const char* src){
@@ -31,7 +38,7 @@ namespace misc {
LOG(std::string("strcpyT sizes dest src ")
+std::to_string(s_dest)+ " "
+std::to_string(strlen(src))+ " "
- ,nitrokey::log::Loglevel::DEBUG);
+ ,nitrokey::log::Loglevel::DEBUG_L2);
if (strlen(src) > s_dest){
throw TooLongStringException(strlen(src), s_dest, src);
}