Removed strcpy use.

This commit is contained in:
Armin Novak 2019-10-29 10:23:48 +01:00
parent f01e042211
commit 993b79f1bd
2 changed files with 12 additions and 8 deletions

View File

@ -300,7 +300,7 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
if (init_external_addin(plugin) < 0)
return FALSE;
strcpy(channelDef.name, RDP2TCP_CHAN_NAME);
strncpy(channelDef.name, RDP2TCP_CHAN_NAME, sizeof(channelDef.name));
channelDef.options =
CHANNEL_OPTION_INITIALIZED |
CHANNEL_OPTION_ENCRYPT_RDP |

View File

@ -13,13 +13,13 @@ typedef struct
const char* expected_result;
} certificate_test_t;
char* crypto_cert_subject_common_name_wo_length(X509* xcert)
static char* crypto_cert_subject_common_name_wo_length(X509* xcert)
{
int length;
return crypto_cert_subject_common_name(xcert, & length);
}
char* certificate_path()
static char* certificate_path(void)
{
/*
Assume the .pem file is in the same directory as this source file.
@ -37,9 +37,13 @@ char* certificate_path()
if (last_dirsep)
{
char* result = malloc(last_dirsep - file + 1 + strnlen(filename, sizeof(filename)) + 1);
strncpy(result, file, (last_dirsep - file + 1));
strcpy(result + (last_dirsep - file + 1), filename);
const size_t filenameLen = strnlen(filename, sizeof(filename));
const size_t dirsepLen = last_dirsep - file + 1;
char* result = malloc(dirsepLen + filenameLen + 1);
if (!result)
return NULL;
strncpy(result, file, dirsepLen);
strncpy(result + dirsepLen, filename, filenameLen + 1);
return result;
}
else
@ -49,7 +53,7 @@ char* certificate_path()
}
}
const certificate_test_t certificate_tests[] =
static const certificate_test_t certificate_tests[] =
{
{
@ -98,7 +102,7 @@ const certificate_test_t certificate_tests[] =
int TestCertificateFile(const char* certificate_path, const certificate_test_t* certificate_tests,
static int TestCertificateFile(const char* certificate_path, const certificate_test_t* certificate_tests,
int count)
{
X509* certificate;