aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NK_C_API.cc4
-rw-r--r--NK_C_API.h4
2 files changed, 5 insertions, 3 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);
});
}
diff --git a/NK_C_API.h b/NK_C_API.h
index 3a6aa2a..858f046 100644
--- a/NK_C_API.h
+++ b/NK_C_API.h
@@ -28,13 +28,15 @@
#ifdef _MSC_VER
#define NK_C_API __declspec(dllexport)
#else
-#define NK_C_API
+#define NK_C_API
#endif
#ifdef __cplusplus
extern "C" {
#endif
+ static const int MAXIMUM_STR_REPLY_LENGTH = 8192;
+
/**
* The Nitrokey device models supported by the API.
*/