summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>2018-11-26 17:16:51 +0100
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>2018-12-03 14:37:26 +0000
commit4437a93b733df83365798950ada5f7d598877407 (patch)
tree0829b98c563aca9ab2e57c85a02ef6dcc0cb42a5
parentc54ed8bd81a76ec23fd0d6e144ea8781623c1ec7 (diff)
downloadkey-manager-4437a93b733df83365798950ada5f7d598877407.tar.gz
key-manager-4437a93b733df83365798950ada5f7d598877407.tar.bz2
key-manager-4437a93b733df83365798950ada5f7d598877407.zip
Fix SVACE and C++ issues
Change-Id: Idfed338ad6f632556585e5749817bb882cbe0251
-rw-r--r--src/manager/main/socket-manager.cpp1
-rw-r--r--src/manager/service/access-control.cpp4
-rw-r--r--src/manager/service/access-control.h1
-rw-r--r--src/manager/service/file-system.cpp2
-rw-r--r--src/manager/service/key-provider.cpp9
-rw-r--r--tests/encryption-scheme/scheme-test.cpp3
6 files changed, 14 insertions, 6 deletions
diff --git a/src/manager/main/socket-manager.cpp b/src/manager/main/socket-manager.cpp
index db3f2a6..60c7c77 100644
--- a/src/manager/main/socket-manager.cpp
+++ b/src/manager/main/socket-manager.cpp
@@ -202,6 +202,7 @@ SocketManager::SocketManager() :
if (-1 == filefd) {
LogError("Error in SignalService.GetDescriptor()");
delete signalService;
+ signalService = nullptr;
} else {
auto &desc2 = CreateDefaultReadSocketDescription(filefd, false);
desc2.service = signalService;
diff --git a/src/manager/service/access-control.cpp b/src/manager/service/access-control.cpp
index 0704147..e57539b 100644
--- a/src/manager/service/access-control.cpp
+++ b/src/manager/service/access-control.cpp
@@ -31,6 +31,10 @@ const uid_t SYSTEM_SVC_MAX_UID = (5000 - 1);
namespace CKM {
+AccessControl::AccessControl() : m_ccMode(false)
+{
+}
+
void AccessControl::updateCCMode()
{
/* newMode should be extracted from global property like buxton in product */
diff --git a/src/manager/service/access-control.h b/src/manager/service/access-control.h
index 4488b92..3e50ce3 100644
--- a/src/manager/service/access-control.h
+++ b/src/manager/service/access-control.h
@@ -32,6 +32,7 @@ namespace CKM {
class AccessControl {
public:
+ AccessControl();
/**
* return true if client uid is from the system services uid space
*/
diff --git a/src/manager/service/file-system.cpp b/src/manager/service/file-system.cpp
index 79f8081..6a70c20 100644
--- a/src/manager/service/file-system.cpp
+++ b/src/manager/service/file-system.cpp
@@ -187,7 +187,7 @@ int FileSystem::init()
{
errno = 0;
- if ((mkdir(RW_DATA_DIR, 0700)) && (errno != EEXIST)) {
+ if ((mkdir(RW_DATA_DIR, S_IRWXU)) && (errno != EEXIST)) {
int err = errno;
LogError("Error in mkdir " << RW_DATA_DIR << ". Reason: " << GetErrnoString(
err));
diff --git a/src/manager/service/key-provider.cpp b/src/manager/service/key-provider.cpp
index 95c68af..a1bc1e5 100644
--- a/src/manager/service/key-provider.cpp
+++ b/src/manager/service/key-provider.cpp
@@ -69,10 +69,11 @@ void WrappedKeyAndInfoContainer::setKeyInfoKeyLength(const unsigned int length)
void WrappedKeyAndInfoContainer::setKeyInfoClient(const std::string resized_client)
{
- strncpy(
- wrappedKeyAndInfo->keyInfo.client,
- resized_client.c_str(),
- MAX_CLIENT_ID_SIZE-1);
+ if (resized_client.size() >= sizeof(wrappedKeyAndInfo->keyInfo.client)) {
+ ThrowErr(Exc::InternalError, "Client name too long");
+ }
+
+ strcpy(wrappedKeyAndInfo->keyInfo.client, resized_client.c_str());
}
void WrappedKeyAndInfoContainer::setKeyInfoSalt(const unsigned char *salt,
diff --git a/tests/encryption-scheme/scheme-test.cpp b/tests/encryption-scheme/scheme-test.cpp
index 66afdbc..d851f42 100644
--- a/tests/encryption-scheme/scheme-test.cpp
+++ b/tests/encryption-scheme/scheme-test.cpp
@@ -60,6 +60,7 @@ RawBuffer TEST_DATA(TEST_DATA_STR.begin(), TEST_DATA_STR.end());
const Password TEST_PASS = "custom user password";
const size_t IV_LEN = 16;
const size_t CHAIN_LEN = 3;
+const mode_t MODE_0644 = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
enum {
NO_PASS = 0,
@@ -348,7 +349,7 @@ void restoreFile(const string &filename)
FdPtr sourceFdPtr(&sourceFd);
- int targetFd = TEMP_FAILURE_RETRY(creat(targetPath.c_str(), 0644));
+ int targetFd = TEMP_FAILURE_RETRY(creat(targetPath.c_str(), MODE_0644));
err = errno;
BOOST_REQUIRE_MESSAGE(targetFd > 0,
"Creating " << targetPath << " failed: " << GetErrnoString(err));