Debian Codegraph @

channels/remdesk/common/remdesk_common.c

raw symbols SCIP
1 /**
2 * FreeRDP: A Remote Desktop Protocol Implementation
3 * Remote Assistance Virtual Channel - common components
4 *
5 * Copyright 2024 Armin Novak <[email protected]>
6 * Copyright 2024 Thincast Technologies GmbH
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
21 #include "remdesk_common.h"cxx . . $ `<file>/channels/remdesk/common/remdesk_common.h`/
22
23 #include <freerdp/channels/log.h>cxx . . $ `<file>/include/freerdp/channels/log.h`/
24 #define TAGcxx . . $ `channels/remdesk/common/remdesk_common.c:24:9`! CHANNELS_TAGcxx . . $ `include/freerdp/channels/log.h:26:9`!("remdesk.common")
25
26 UINTcxx . . $ UINT# remdesk_write_channel_headercxx . . $ remdesk_write_channel_header(1c2630d49def05fa).(wStreamcxx . . $ wStream#* s, const REMDESK_CHANNEL_HEADERcxx . . $ REMDESK_CHANNEL_HEADER#* header)
27 {
28 WCHARcxx . . $ WCHAR# ChannelNameW[32] = WINPR_C_ARRAY_INITcxx . . $ `winpr/include/winpr/platform.h:87:9`!;
29
30 WINPR_ASSERTcxx . . $ `winpr/include/winpr/assert-api.h:76:9`!(s);
31 WINPR_ASSERTcxx . . $ `winpr/include/winpr/assert-api.h:76:9`!(header);
32
33 for (size_t index = 0; index < 32; index++)
34 {
35 ChannelNameW[index] = (WCHARcxx . . $ WCHAR#)header->ChannelNamecxx . . $ $anonymous_type_2420c9dcff76f817_0#ChannelName.[index];
36 }
37
38 const size_t ChannelNameLen =
39 (strnlencxx . . $ strnlen(ac5a385650b4bde5).(header->ChannelNamecxx . . $ $anonymous_type_2420c9dcff76f817_0#ChannelName., sizeof(header->ChannelNamecxx . . $ $anonymous_type_2420c9dcff76f817_0#ChannelName.)) + 1) * sizeof(WCHARcxx . . $ WCHAR#);
40 WINPR_ASSERTcxx . . $ `winpr/include/winpr/assert-api.h:76:9`!(ChannelNameLen <= ARRAYSIZEcxx . . $ `winpr/include/winpr/spec.h:962:9`!(header->ChannelName));
41
42 Stream_Write_UINT32cxx . . $ `winpr/include/winpr/stream.h:1070:9`!(s, (UINT32)ChannelNameLen); /* ChannelNameLen (4 bytes) */
43 Stream_Write_UINT32cxx . . $ `winpr/include/winpr/stream.h:1070:9`!(s, header->DataLength); /* DataLen (4 bytes) */
44 Stream_Writecxx . . $ Stream_Write(6afa9478ce9fa6e6).(s, ChannelNameW, ChannelNameLen); /* ChannelName (variable) */
45 return CHANNEL_RC_OKcxx . . $ `winpr/include/winpr/wtsapi.h:159:9`!;
46 }
47
48 UINTcxx . . $ UINT# remdesk_write_ctl_headercxx . . $ remdesk_write_ctl_header(81e24ca5827d1ffa).(wStreamcxx . . $ wStream#* s, const REMDESK_CTL_HEADERcxx . . $ REMDESK_CTL_HEADER#* ctlHeader)
49 {
50 WINPR_ASSERTcxx . . $ `winpr/include/winpr/assert-api.h:76:9`!(ctlHeader);
51 const UINTcxx . . $ UINT# error = remdesk_write_channel_headercxx . . $ remdesk_write_channel_header(1c2630d49def05fa).(s, &ctlHeader->chcxx . . $ $anonymous_type_2420c9dcff76f817_1#ch.);
52
53 if (error != 0)
54 {
55 WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/common/remdesk_common.c:24:9`!, "remdesk_write_channel_header failed with error %" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`! "!", error);
56 return error;
57 }
58
59 Stream_Write_UINT32cxx . . $ `winpr/include/winpr/stream.h:1070:9`!(s, ctlHeader->msgType); /* msgType (4 bytes) */
60 return CHANNEL_RC_OKcxx . . $ `winpr/include/winpr/wtsapi.h:159:9`!;
61 }
62
63 UINTcxx . . $ UINT# remdesk_read_channel_headercxx . . $ remdesk_read_channel_header(21b6382422964d34).(wStreamcxx . . $ wStream#* s, REMDESK_CHANNEL_HEADERcxx . . $ REMDESK_CHANNEL_HEADER#* header)
64 {
65 UINT32cxx . . $ UINT32# ChannelNameLen = 0;
66
67 if (!Stream_CheckAndLogRequiredLengthcxx . . $ `winpr/include/winpr/stream.h:127:9`!(TAGcxx . . $ `channels/remdesk/common/remdesk_common.c:24:9`!, s, 8))
68 return CHANNEL_RC_NO_MEMORYcxx . . $ `winpr/include/winpr/wtsapi.h:171:9`!;
69
70 Stream_Read_UINT32cxx . . $ `winpr/include/winpr/stream.h:683:9`!(s, ChannelNameLen); /* ChannelNameLen (4 bytes) */
71 Stream_Read_UINT32cxx . . $ `winpr/include/winpr/stream.h:683:9`!(s, header->DataLength); /* DataLen (4 bytes) */
72
73 if (ChannelNameLen > 64)
74 {
75 WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/common/remdesk_common.c:24:9`!, "ChannelNameLen > 64!");
76 return ERROR_INVALID_DATAcxx . . $ `winpr/include/winpr/error.h:198:9`!;
77 }
78
79 if ((ChannelNameLen % 2) != 0)
80 {
81 WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/common/remdesk_common.c:24:9`!, "(ChannelNameLen %% 2) != 0!");
82 return ERROR_INVALID_DATAcxx . . $ `winpr/include/winpr/error.h:198:9`!;
83 }
84
85 if (Stream_Read_UTF16_String_As_UTF8_Buffercxx . . $ Stream_Read_UTF16_String_As_UTF8_Buffer(a952c57ead14e352).(s, ChannelNameLen / sizeof(WCHARcxx . . $ WCHAR#),
86 header->ChannelNamecxx . . $ $anonymous_type_2420c9dcff76f817_0#ChannelName.,
87 ARRAYSIZEcxx . . $ `winpr/include/winpr/spec.h:962:9`!(header->ChannelName)) < 0)
88 return ERROR_INVALID_DATAcxx . . $ `winpr/include/winpr/error.h:198:9`!;
89
90 return CHANNEL_RC_OKcxx . . $ `winpr/include/winpr/wtsapi.h:159:9`!;
91 }
92
93 UINTcxx . . $ UINT# remdesk_prepare_ctl_headercxx . . $ remdesk_prepare_ctl_header(392ed5bfdedf0817).(REMDESK_CTL_HEADERcxx . . $ REMDESK_CTL_HEADER#* ctlHeader, UINT32cxx . . $ UINT32# msgType, size_t msgSize)
94 {
95 WINPR_ASSERTcxx . . $ `winpr/include/winpr/assert-api.h:76:9`!(ctlHeader);
96
97 if (msgSize > UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:124:10`! - 4)
98 return ERROR_INVALID_PARAMETERcxx . . $ `winpr/include/winpr/error.h:252:9`!;
99
100 ctlHeader->msgTypecxx . . $ $anonymous_type_2420c9dcff76f817_1#msgType. = msgType;
101 (void)sprintf_scxx . . $ `winpr/include/winpr/string.h:251:9`!(ctlHeader->chcxx . . $ $anonymous_type_2420c9dcff76f817_1#ch..ChannelNamecxx . . $ $anonymous_type_2420c9dcff76f817_0#ChannelName., ARRAYSIZEcxx . . $ `winpr/include/winpr/spec.h:962:9`!(ctlHeader->ch.ChannelName),
102 REMDESK_CHANNEL_CTL_NAMEcxx . . $ `include/freerdp/channels/remdesk.h:93:9`!);
103 ctlHeader->chcxx . . $ $anonymous_type_2420c9dcff76f817_1#ch..DataLengthcxx . . $ $anonymous_type_2420c9dcff76f817_0#DataLength. = (UINT32cxx . . $ UINT32#)(4UL + msgSize);
104 return CHANNEL_RC_OKcxx . . $ `winpr/include/winpr/wtsapi.h:159:9`!;
105 }