aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-08-09 11:48:05 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-08-09 18:34:00 +0200
commit08e63f308f5322040794be1e768f0dd400d43a06 (patch)
tree1cac91c377c83f4968b28f20778fcae29751e3f1
parent15e4882602cf88eb503b061dbfaa28412751d0fb (diff)
downloadlibnitrokey-08e63f308f5322040794be1e768f0dd400d43a06.tar.gz
libnitrokey-08e63f308f5322040794be1e768f0dd400d43a06.tar.bz2
Clear string result from get status
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r--NK_C_API.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/NK_C_API.cc b/NK_C_API.cc
index 538e7a9..556ec65 100644
--- a/NK_C_API.cc
+++ b/NK_C_API.cc
@@ -146,11 +146,17 @@ extern uint8_t* NK_read_config(){
}
+void clear_string(std::string &s){
+ std::fill(s.begin(), s.end(), ' ');
+}
+
extern const char * NK_status() {
auto m = NitrokeyManager::instance();
return get_with_string_result([&](){
- string s = m->get_status(); //FIXME string without clearing
- return strdup(s.c_str());
+ string && s = m->get_status();
+ char * rs = strdup(s.c_str());
+ clear_string(s);
+ return rs;
});
}