[warnings] fixed bugprone-not-null-terminated-result

This commit is contained in:
akallabeth 2024-09-16 07:24:32 +02:00
parent a19305569d
commit befa4233ad
No known key found for this signature in database
GPG Key ID: A49454A3FC909FD5
4 changed files with 12 additions and 6 deletions

View File

@ -1176,7 +1176,8 @@ static UINT rdpdr_process_connect(rdpdrPlugin* rdpdr)
if (!drive->Path)
continue;
BOOL hotplugAll = strncmp(drive->Path, "*", 2) == 0;
const char wildcard[] = "*";
BOOL hotplugAll = strncmp(drive->Path, wildcard, sizeof(wildcard)) == 0;
BOOL hotplugLater = strncmp(drive->Path, DynamicDrives, sizeof(DynamicDrives)) == 0;
if (hotplugAll || hotplugLater)

View File

@ -539,13 +539,15 @@ int TestClientRdpFile(int argc, char* argv[])
if (iValue != 456)
return -1;
const char microsoft[] = "microsoft";
sValue = freerdp_client_rdp_file_get_string_option(file, "vendor string");
if (strncmp(sValue, "microsoft", 10) != 0)
if (strncmp(sValue, microsoft, sizeof(microsoft)) != 0)
goto fail;
const char apple[] = "apple";
freerdp_client_rdp_file_set_string_option(file, "vendor string", "apple");
sValue = freerdp_client_rdp_file_get_string_option(file, "vendor string");
if (strncmp(sValue, "apple", 6) != 0)
if (strncmp(sValue, apple, sizeof(apple)) != 0)
goto fail;
freerdp_client_rdp_file_set_string_option(file, "fruits", "banana,oranges");

View File

@ -42,6 +42,8 @@ struct rdp_persistent_cache
UINT32 bmpSize;
};
static const char sig_str[] = "RDP8bmp";
int persistent_cache_get_version(rdpPersistentCache* persistent)
{
WINPR_ASSERT(persistent);
@ -258,7 +260,7 @@ static int persistent_cache_open_read(rdpPersistentCache* persistent)
if (fread(sig, 8, 1, persistent->fp) != 1)
return -1;
if (!strncmp((const char*)sig, "RDP8bmp", 8))
if (memcmp(sig, sig_str, sizeof(sig_str)) == 0)
persistent->version = 3;
else
persistent->version = 2;
@ -298,7 +300,7 @@ static int persistent_cache_open_write(rdpPersistentCache* persistent)
if (persistent->version == 3)
{
PERSISTENT_CACHE_HEADER_V3 header = { 0 };
strncpy((char*)header.sig, "RDP8bmp", 8);
memcpy(header.sig, sig_str, MIN(sizeof(header.sig), sizeof(sig_str)));
header.flags = 0x00000006;
if (fwrite(&header, sizeof(header), 1, persistent->fp) != 1)

View File

@ -922,11 +922,12 @@ static const Mech* guessMech(PSecBuffer input_buffer, BOOL* spNego, WinPrAsn1_OI
WinPrAsn1Decoder decoder;
WinPrAsn1Decoder appDecoder;
WinPrAsn1_tagId tag = 0;
const char ssp[] = "NTLMSSP";
*spNego = FALSE;
/* Check for NTLM token */
if (input_buffer->cbBuffer >= 8 && strncmp(input_buffer->pvBuffer, "NTLMSSP", 8) == 0)
if (input_buffer->cbBuffer >= 8 && strncmp(input_buffer->pvBuffer, ssp, sizeof(ssp)) == 0)
{
*oid = ntlm_OID;
return negotiate_GetMechByOID(&ntlm_OID);