aboutsummaryrefslogtreecommitdiff
path: root/NitrokeyManager.cc
diff options
context:
space:
mode:
Diffstat (limited to 'NitrokeyManager.cc')
-rw-r--r--NitrokeyManager.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc
index c88f717..d827292 100644
--- a/NitrokeyManager.cc
+++ b/NitrokeyManager.cc
@@ -2,6 +2,7 @@
#include <iostream>
#include "include/NitrokeyManager.h"
#include "include/LibraryException.h"
+#include <algorithm>
namespace nitrokey{
@@ -157,10 +158,13 @@ namespace nitrokey{
return erase_slot(slot_number, temporary_password);
}
- #include <cassert>
template <typename T, typename U>
- void vector_copy(T& dest, std::vector<U> vec){
- assert(sizeof(dest)>=vec.size());
+ void vector_copy(T& dest, std::vector<U> &vec){
+ const size_t d_size = sizeof(dest);
+ if(d_size < vec.size()){
+ throw TargetBufferSmallerThanSource(vec.size(), d_size);
+ }
+ std::fill(dest, dest+d_size, 0);
std::copy(vec.begin(), vec.end(), dest);
}