Commit f0449b12 authored by Guillaume Roguez's avatar Guillaume Roguez Committed by gerrit2

security: fix resource leaks in TlsVAlidator

This patch fix two calls to strdup() without any free().

Change-Id: I8619794e71d4165c154ba6ddd89bf6237e444a67
Tuleap: #906
parent 99cd560e
......@@ -846,9 +846,9 @@ TlsValidator::CheckResult TlsValidator::privateKeyDirectoryPermissions()
if (privateKeyPath_.empty())
return TlsValidator::CheckResult(CheckValues::UNSUPPORTED, "");
char* dup = strdup(privateKeyPath_.c_str());
#ifndef WIN32_NATIVE
const char* dir = dirname(dup);
auto path = std::unique_ptr<char, decltype(free)&> (strdup(privateKeyPath_.c_str()), free);
const char* dir = dirname(path.get());
#else
char* dir;
_splitpath(certificatePath_.c_str(), nullptr, dir, nullptr, nullptr);
......@@ -869,9 +869,9 @@ TlsValidator::CheckResult TlsValidator::privateKeyDirectoryPermissions()
TlsValidator::CheckResult TlsValidator::publicKeyDirectoryPermissions()
{
char* dup = strdup(certificatePath_.c_str());
#ifndef WIN32_NATIVE
const char* dir = dirname(dup);
auto path = std::unique_ptr<char, decltype(free)&>(strdup(certificatePath_.c_str()), free);
const char* dir = dirname(path.get());
#else
char* dir;
_splitpath(certificatePath_.c_str(), nullptr, dir, nullptr, nullptr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment