From dc15fc719794e64856818c43f9ab20968d75ea01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Tue, 28 Sep 2021 14:58:41 +0200 Subject: [PATCH] Remove implicit handle of final \0 in ByteArray --- include/libgourou_common.h | 2 +- src/bytearray.cpp | 4 ++-- src/libgourou.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/libgourou_common.h b/include/libgourou_common.h index fc701a0..d14b054 100644 --- a/include/libgourou_common.h +++ b/include/libgourou_common.h @@ -293,7 +293,7 @@ namespace gourou */ static inline void writeFile(std::string path, ByteArray& data) { - writeFile(path, data.data(), data.length()-1); + writeFile(path, data.data(), data.length()); } /** diff --git a/src/bytearray.cpp b/src/bytearray.cpp index 11cb21c..08d9c92 100644 --- a/src/bytearray.cpp +++ b/src/bytearray.cpp @@ -37,14 +37,14 @@ namespace gourou ByteArray::ByteArray(const char* data, int length) { if (length == -1) - length = strlen(data) + 1; + length = strlen(data); initData((const unsigned char*)data, (unsigned int) length); } ByteArray::ByteArray(const std::string& str) { - initData((unsigned char*)str.c_str(), (unsigned int)str.length() + 1); + initData((unsigned char*)str.c_str(), (unsigned int)str.length()); } void ByteArray::initData(const unsigned char* data, unsigned int length) diff --git a/src/libgourou.cpp b/src/libgourou.cpp index 4d41649..f336b96 100644 --- a/src/libgourou.cpp +++ b/src/libgourou.cpp @@ -907,7 +907,7 @@ namespace gourou ByteArray privateLicenseKey = ByteArray::fromBase64(user->getPrivateLicenseKey()); /* In adobekey.py, we get base64 decoded data [26:] */ - write(fd, privateLicenseKey.data()+26, privateLicenseKey.length()-1-26); + write(fd, privateLicenseKey.data()+26, privateLicenseKey.length()-26); close(fd); }