Merge pull request #4320 from ondrejholy/coverity-fixes

Coverity Scan fixes
This commit is contained in:
Martin Fleisz 2017-12-20 14:17:20 +01:00 committed by GitHub
commit 80a49f46dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 14 deletions

View File

@ -72,7 +72,7 @@ static BOOL tsmf_alsa_open(ITSMFAudioDevice *audio, const char *device)
}
else
{
strncpy(alsa->device, device, sizeof(alsa->device));
strncpy(alsa->device, device, sizeof(alsa->device) - 1);
}
return tsmf_alsa_open_device(alsa);
}

View File

@ -81,7 +81,7 @@ static BOOL tsmf_oss_open(ITSMFAudioDevice* audio, const char* device)
}
else
{
strncpy(oss->dev_name, device, sizeof(oss->dev_name));
strncpy(oss->dev_name, device, sizeof(oss->dev_name) - 1);
}
if ((oss->pcm_handle = open(oss->dev_name, O_WRONLY)) < 0)

View File

@ -115,7 +115,7 @@ static BOOL tsmf_pulse_open(ITSMFAudioDevice *audio, const char *device)
TSMFPulseAudioDevice *pulse = (TSMFPulseAudioDevice *) audio;
if(device)
{
strcpy(pulse->device, device);
strncpy(pulse->device, device, sizeof(pulse->device) - 1);
}
pulse->mainloop = pa_threaded_mainloop_new();
if(!pulse->mainloop)

View File

@ -615,17 +615,11 @@ BOOL rdp_send_data_pdu(rdpRdp* rdp, wStream* s, BYTE type, UINT16 channel_id)
BOOL rdp_send_message_channel_pdu(rdpRdp* rdp, wStream* s, UINT16 sec_flags)
{
UINT16 length;
UINT32 sec_bytes;
size_t sec_hold;
UINT32 pad;
length = Stream_GetPosition(s);
Stream_SetPosition(s, 0);
rdp_write_header(rdp, s, length, rdp->mcs->messageChannelId);
sec_bytes = rdp_get_sec_bytes(rdp, sec_flags);
sec_hold = Stream_GetPosition(s);
Stream_Seek(s, sec_bytes);
Stream_SetPosition(s, sec_hold);
if (!rdp_security_stream_out(rdp, s, length, sec_flags, &pad))
return FALSE;

View File

@ -524,9 +524,9 @@ static void fips_expand_key_bits(BYTE* in, BYTE* out)
p = b / 8;
r = b % 8;
if (r == 0)
if (r <= 1)
{
out[i] = buf[p] & 0xfe;
out[i] = (buf[p] << r) & 0xfe;
}
else
{

View File

@ -309,6 +309,7 @@ void per_write_enumerated(wStream* s, BYTE enumerated, BYTE count)
* Read PER OBJECT_IDENTIFIER (OID).
* @param s stream
* @param oid object identifier (OID)
* @warning It works correctly only for limited set of OIDs.
* @return
*/
@ -328,8 +329,8 @@ BOOL per_read_object_identifier(wStream* s, BYTE oid[6])
return FALSE;
Stream_Read_UINT8(s, t12); /* first two tuples */
a_oid[0] = (t12 >> 4);
a_oid[1] = (t12 & 0x0F);
a_oid[0] = t12 / 40;
a_oid[1] = t12 % 40;
Stream_Read_UINT8(s, a_oid[2]); /* tuple 3 */
Stream_Read_UINT8(s, a_oid[3]); /* tuple 4 */
@ -352,11 +353,12 @@ BOOL per_read_object_identifier(wStream* s, BYTE oid[6])
* Write PER OBJECT_IDENTIFIER (OID)
* @param s stream
* @param oid object identifier (oid)
* @warning It works correctly only for limited set of OIDs.
*/
void per_write_object_identifier(wStream* s, BYTE oid[6])
{
BYTE t12 = (oid[0] << 4) & (oid[1] & 0x0F);
BYTE t12 = oid[0] * 40 + oid[1];
Stream_Write_UINT8(s, 5); /* length */
Stream_Write_UINT8(s, t12); /* first two tuples */
Stream_Write_UINT8(s, oid[2]); /* tuple 3 */