Coverage Report

Created: 2026-11-10 06:44

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/FreeRDP/channels/disp/disp_common.c
Line
Count
Source
1
/**
2
 * FreeRDP: A Remote Desktop Protocol Implementation
3
 * RDPEDISP Virtual Channel Extension
4
 *
5
 * Copyright 2019 Kobi Mizrachi <kmizrachi18@gmail.com>
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 */
19
20
#include <freerdp/config.h>
21
22
#include <winpr/crt.h>
23
#include <winpr/stream.h>
24
#include <freerdp/channels/log.h>
25
26
#define TAG CHANNELS_TAG("disp.common")
27
28
#include "disp_common.h"
29
30
/**
31
 * Function description
32
 *
33
 * @return 0 on success, otherwise a Win32 error code
34
 */
35
UINT disp_read_header(wStream* s, DISPLAY_CONTROL_HEADER* header, size_t* packetLen)
36
0
{
37
0
  if (packetLen)
38
0
    *packetLen = 0;
39
40
0
  if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
41
0
    return ERROR_INVALID_DATA;
42
43
0
  Stream_Read_UINT32(s, header->type);
44
0
  Stream_Read_UINT32(s, header->length);
45
0
  if (header->length < 8)
46
0
  {
47
0
    WLog_ERR(TAG, "Invalid header length %" PRIu32 ", require at least 8", header->length);
48
0
    return ERROR_INVALID_DATA;
49
0
  }
50
0
  if (!Stream_CheckAndLogRequiredLength(TAG, s, header->length - 8))
51
0
    return ERROR_INVALID_DATA;
52
53
0
  if (packetLen)
54
0
    *packetLen = header->length - 8;
55
56
0
  return CHANNEL_RC_OK;
57
0
}
58
59
/**
60
 * Function description
61
 *
62
 * @return 0 on success, otherwise a Win32 error code
63
 */
64
UINT disp_write_header(wStream* s, const DISPLAY_CONTROL_HEADER* header)
65
0
{
66
0
  Stream_Write_UINT32(s, header->type);
67
0
  Stream_Write_UINT32(s, header->length);
68
0
  return CHANNEL_RC_OK;
69
0
}