aboutsummaryrefslogtreecommitdiff
path: root/unittest
diff options
context:
space:
mode:
authorRobin Krahl <me@robin-krahl.de>2018-04-04 15:06:03 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2018-04-10 07:58:32 +0200
commit2f7b58abcee6ef32a927b3bd43070bbea205656b (patch)
treefc2ab4ee7ac556d052c7dc9a52959497b0291fdd /unittest
parentf9f89587026cd22115f06c216e2d69c4142c7060 (diff)
downloadlibnitrokey-2f7b58abcee6ef32a927b3bd43070bbea205656b.tar.gz
libnitrokey-2f7b58abcee6ef32a927b3bd43070bbea205656b.tar.bz2
Null-terminate the argument for strtoul
As discussed in issue #95, the buffer passed to strtoul must be null-terminated. This patch null-terminates the buffer used in hexStringToByte in the test_HOTP unit test to avoid a buffer over-read.
Diffstat (limited to 'unittest')
-rw-r--r--unittest/test_HOTP.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/unittest/test_HOTP.cc b/unittest/test_HOTP.cc
index 520faaf..c13fb8e 100644
--- a/unittest/test_HOTP.cc
+++ b/unittest/test_HOTP.cc
@@ -36,7 +36,8 @@ using namespace nitrokey::misc;
void hexStringToByte(uint8_t data[], const char* hexString){
REQUIRE(strlen(hexString)%2==0);
- char buf[2];
+ char buf[3];
+ buf[2] = '\0';
for(int i=0; i<strlen(hexString); i++){
buf[i%2] = hexString[i];
if (i%2==1){