summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile4
-rw-r--r--src/PracticalSocket.cpp1
-rw-r--r--src/anytun.cpp2
-rw-r--r--src/authAlgo.cpp1
-rw-r--r--src/bsd/tunDevice.cpp1
-rw-r--r--src/cipher.cpp5
-rw-r--r--src/keyDerivation.cpp5
-rw-r--r--src/linux/tunDevice.cpp3
8 files changed, 19 insertions, 3 deletions
diff --git a/src/Makefile b/src/Makefile
index eca9774..11b54e9 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -11,8 +11,8 @@ LD = g++
LDFLAGS = -g -Wall -O2 -lpthread -lgcrypt -lgpg-error -lboost_serialization
ifeq ($(TARGET),Linux)
-# CFLAGS += -D_XOPEN_SOURCE=600
-# CCFLAGS += -D_XOPEN_SOURCE=600
+ CFLAGS += -D_XOPEN_SOURCE=600
+ CCFLAGS += -D_XOPEN_SOURCE=600
LDFLAGS += -ldl
endif
ifeq ($(TARGET),OpenBSD)
diff --git a/src/PracticalSocket.cpp b/src/PracticalSocket.cpp
index 3ff286f..e08cac0 100644
--- a/src/PracticalSocket.cpp
+++ b/src/PracticalSocket.cpp
@@ -83,6 +83,7 @@ SocketException::SocketException(const string &message, bool inclSysMsg)
if (inclSysMsg) {
userMessage.append(": ");
char buf[STERROR_TEXT_MAX];
+ buf[0] = 0;
strerror_r(errno, buf, STERROR_TEXT_MAX);
userMessage.append(buf);
}
diff --git a/src/anytun.cpp b/src/anytun.cpp
index ed6d845..fdeaead 100644
--- a/src/anytun.cpp
+++ b/src/anytun.cpp
@@ -364,6 +364,7 @@ bool initLibGCrypt()
gcry_error_t err = gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
if( err ) {
char buf[STERROR_TEXT_MAX];
+ buf[0] = 0;
std::cout << "initLibGCrypt: Failed to disable secure memory: " << gpg_strerror_r(err, buf, STERROR_TEXT_MAX) << std::endl;
return false;
}
@@ -372,6 +373,7 @@ bool initLibGCrypt()
err = gcry_control(GCRYCTL_INITIALIZATION_FINISHED);
if( err ) {
char buf[STERROR_TEXT_MAX];
+ buf[0] = 0;
std::cout << "initLibGCrypt: Failed to finish initialization: " << gpg_strerror_r(err, buf, STERROR_TEXT_MAX) << std::endl;
return false;
}
diff --git a/src/authAlgo.cpp b/src/authAlgo.cpp
index 617c93b..770bffe 100644
--- a/src/authAlgo.cpp
+++ b/src/authAlgo.cpp
@@ -75,6 +75,7 @@ void Sha1AuthAlgo::setKey(Buffer& key)
gcry_error_t err = gcry_md_setkey( ctx_, key.getBuf(), key.getLength() );
if( err ) {
char buf[STERROR_TEXT_MAX];
+ buf[0] = 0;
cLog.msg(Log::PRIO_ERR) << "Sha1AuthAlgo::setKey: Failed to set cipher key: " << gpg_strerror_r(err, buf, STERROR_TEXT_MAX);
}
}
diff --git a/src/bsd/tunDevice.cpp b/src/bsd/tunDevice.cpp
index 0fe27f5..b47a1da 100644
--- a/src/bsd/tunDevice.cpp
+++ b/src/bsd/tunDevice.cpp
@@ -91,6 +91,7 @@ TunDevice::TunDevice(const char* dev_name, const char* dev_type, const char* ifc
msg.append(device_file);
msg.append("): ");
char buf[STERROR_TEXT_MAX];
+ buf[0] = 0;
strerror_r(errno, buf, STERROR_TEXT_MAX);
msg.append(buf);
}
diff --git a/src/cipher.cpp b/src/cipher.cpp
index 593218f..3667290 100644
--- a/src/cipher.cpp
+++ b/src/cipher.cpp
@@ -80,6 +80,7 @@ AesIcmCipher::AesIcmCipher() : cipher_(NULL)
gcry_error_t err = gcry_cipher_open( &cipher_, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CTR, 0 );
if( err ) {
char buf[STERROR_TEXT_MAX];
+ buf[0] = 0;
cLog.msg(Log::PRIO_CRIT) << "AesIcmCipher::AesIcmCipher: Failed to open cipher" << gpg_strerror_r(err, buf, STERROR_TEXT_MAX);
}
}
@@ -99,6 +100,7 @@ void AesIcmCipher::setKey(Buffer& key)
gcry_error_t err = gcry_cipher_setkey( cipher_, key.getBuf(), key.getLength() );
if( err ) {
char buf[STERROR_TEXT_MAX];
+ buf[0] = 0;
cLog.msg(Log::PRIO_ERR) << "AesIcmCipher::setKey: Failed to set cipher key: " << gpg_strerror_r(err, buf, STERROR_TEXT_MAX);
}
}
@@ -130,6 +132,7 @@ void AesIcmCipher::calc(u_int8_t* in, u_int32_t ilen, u_int8_t* out, u_int32_t o
gcry_error_t err = gcry_cipher_reset( cipher_ );
if( err ) {
char buf[STERROR_TEXT_MAX];
+ buf[0] = 0;
cLog.msg(Log::PRIO_ERR) << "AesIcmCipher: Failed to reset cipher: " << gpg_strerror_r(err, buf, STERROR_TEXT_MAX);
return;
}
@@ -160,6 +163,7 @@ void AesIcmCipher::calc(u_int8_t* in, u_int32_t ilen, u_int8_t* out, u_int32_t o
delete[] ctr_buf;
if( err ) {
char buf[STERROR_TEXT_MAX];
+ buf[0] = 0;
cLog.msg(Log::PRIO_ERR) << "AesIcmCipher: Failed to set cipher CTR: " << gpg_strerror_r(err, buf, STERROR_TEXT_MAX);
return;
}
@@ -167,6 +171,7 @@ void AesIcmCipher::calc(u_int8_t* in, u_int32_t ilen, u_int8_t* out, u_int32_t o
err = gcry_cipher_encrypt( cipher_, out, olen, in, ilen );
if( err ) {
char buf[STERROR_TEXT_MAX];
+ buf[0] = 0;
cLog.msg(Log::PRIO_ERR) << "AesIcmCipher: Failed to generate cipher bitstream: " << gpg_strerror_r(err, buf, STERROR_TEXT_MAX);
return;
}
diff --git a/src/keyDerivation.cpp b/src/keyDerivation.cpp
index eda2189..12ba5d8 100644
--- a/src/keyDerivation.cpp
+++ b/src/keyDerivation.cpp
@@ -72,6 +72,7 @@ void AesIcmKeyDerivation::updateMasterKey()
gcry_error_t err = gcry_cipher_setkey( cipher_, master_key_.getBuf(), master_key_.getLength() );
if( err ) {
char buf[STERROR_TEXT_MAX];
+ buf[0] = 0;
cLog.msg(Log::PRIO_ERR) << "KeyDerivation::updateMasterKey: Failed to set cipher key: " << gpg_strerror_r(err, buf, STERROR_TEXT_MAX);
}
}
@@ -86,6 +87,7 @@ void AesIcmKeyDerivation::init(Buffer key, Buffer salt)
gcry_error_t err = gcry_cipher_open( &cipher_, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CTR, 0 );
if( err ) {
char buf[STERROR_TEXT_MAX];
+ buf[0] = 0;
cLog.msg(Log::PRIO_ERR) << "KeyDerivation::init: Failed to open cipher: " << gpg_strerror_r(err, buf, STERROR_TEXT_MAX);
return;
}
@@ -108,6 +110,7 @@ void AesIcmKeyDerivation::generate(satp_prf_label label, seq_nr_t seq_nr, Buffer
gcry_error_t err = gcry_cipher_reset( cipher_ );
if( err ) {
char buf[STERROR_TEXT_MAX];
+ buf[0] = 0;
cLog.msg(Log::PRIO_ERR) << "KeyDerivation::generate: Failed to reset cipher: " << gpg_strerror_r(err, buf, STERROR_TEXT_MAX);
}
@@ -149,6 +152,7 @@ void AesIcmKeyDerivation::generate(satp_prf_label label, seq_nr_t seq_nr, Buffer
if( err ) {
char buf[STERROR_TEXT_MAX];
+ buf[0] = 0;
cLog.msg(Log::PRIO_ERR) << "KeyDerivation::generate: Failed to set CTR: " << gpg_strerror_r(err, buf, STERROR_TEXT_MAX);
}
@@ -156,6 +160,7 @@ void AesIcmKeyDerivation::generate(satp_prf_label label, seq_nr_t seq_nr, Buffer
err = gcry_cipher_encrypt( cipher_, key, key.getLength(), NULL, 0);
if( err ) {
char buf[STERROR_TEXT_MAX];
+ buf[0] = 0;
cLog.msg(Log::PRIO_ERR) << "KeyDerivation::generate: Failed to generate cipher bitstream: " << gpg_strerror_r(err, buf, STERROR_TEXT_MAX);
}
}
diff --git a/src/linux/tunDevice.cpp b/src/linux/tunDevice.cpp
index a226641..559258b 100644
--- a/src/linux/tunDevice.cpp
+++ b/src/linux/tunDevice.cpp
@@ -28,7 +28,6 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#define _XOPEN_SOURCE 600
#include <string.h>
#include <sstream>
@@ -54,6 +53,7 @@ TunDevice::TunDevice(const char* dev_name, const char* dev_type, const char* ifc
msg.append(DEFAULT_DEVICE);
msg.append("): ");
char buf[STERROR_TEXT_MAX];
+ buf[0] = 0;
strerror_r(errno, buf, STERROR_TEXT_MAX);
msg.append(buf);
throw std::runtime_error(msg);
@@ -83,6 +83,7 @@ TunDevice::TunDevice(const char* dev_name, const char* dev_type, const char* ifc
} else {
std::string msg("tun/tap device ioctl failed: ");
char buf[STERROR_TEXT_MAX];
+ buf[0] = 0;
strerror_r(errno, buf, STERROR_TEXT_MAX);
msg.append(buf);
throw std::runtime_error(msg);