summaryrefslogtreecommitdiff
path: root/NK_C_API.cc
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2018-04-19 13:40:25 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2018-04-19 13:40:25 +0200
commit7a8550dbeda1d05a57a41e4aa0545c625f02ea7e (patch)
tree60d2aec25a62f137372e607579b245e2d4ae9801 /NK_C_API.cc
parent7f5f471d8f3a67fe109e4c8c241de2e1098d275e (diff)
downloadlibnitrokey-7a8550dbeda1d05a57a41e4aa0545c625f02ea7e.tar.gz
libnitrokey-7a8550dbeda1d05a57a41e4aa0545c625f02ea7e.tar.bz2
Return allocated string instead of pointer to a string literal
Issue #110 Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'NK_C_API.cc')
-rw-r--r--NK_C_API.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/NK_C_API.cc b/NK_C_API.cc
index b245940..c398e95 100644
--- a/NK_C_API.cc
+++ b/NK_C_API.cc
@@ -85,7 +85,7 @@ const char* get_with_string_result(T func){
catch (const DeviceCommunicationException &deviceException){
NK_last_command_status = 256-deviceException.getType();
}
- return "";
+ return strndup("", MAXIMUM_STR_REPLY_LENGTH);
}
template <typename T>
@@ -640,7 +640,7 @@ extern "C" {
res += a+";";
}
if (res.size()>0) res.pop_back(); // remove last delimiter char
- return strndup(res.c_str(), 8192); //this buffer size sets limit to over 200 devices ID's
+ return strndup(res.c_str(), MAXIMUM_STR_REPLY_LENGTH);
});
}