Changeset 102064 in vbox for trunk/src/VBox
- Timestamp:
- Nov 10, 2023 2:15:11 PM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/VBoxClient/wayland-helper-ipc.cpp
r101878 r102064 153 153 154 154 vbcl::ipc::packet_t Packet; 155 size_t cbRead;156 155 157 156 AssertPtrReturn(ppvData, VERR_INVALID_PARAMETER); … … 161 160 { 162 161 /* Read IPC message header. */ 163 rc = RTLocalIpcSessionRead(hSession, &Packet, sizeof(Packet), &cbRead);162 rc = RTLocalIpcSessionRead(hSession, &Packet, sizeof(Packet), NULL); 164 163 if (RT_SUCCESS(rc)) 165 164 { 166 if (cbRead == sizeof(Packet)) 167 { 168 bool fCheck = true; 165 bool fCheck = true; 169 166 170 167 #define _CHECK(_cond, _msg, _ptr) \ … … 176 173 } 177 174 178 _CHECK(Packet.u64Crc > 0, "bad crc: 0x%x", Packet.u64Crc); 179 _CHECK(Packet.uSessionId == uSessionId, "bad session id: %u vs %u", (Packet.uSessionId, uSessionId)); 180 _CHECK(Packet.cbData > sizeof(Packet), "bad cbData: %u", Packet.cbData); 181 182 /* Receive the rest of a message. */ 183 if (fCheck) 175 _CHECK(Packet.u64Crc > 0, "bad crc: 0x%x", Packet.u64Crc); 176 _CHECK(Packet.uSessionId == uSessionId, "bad session id: %u vs %u", (Packet.uSessionId, uSessionId)); 177 _CHECK(Packet.cbData > sizeof(Packet), "bad cbData: %u", Packet.cbData); 178 179 /* Receive the rest of a message. */ 180 if (fCheck) 181 { 182 uint8_t *puData; 183 184 puData = (uint8_t *)RTMemAllocZ(Packet.cbData); 185 if (RT_VALID_PTR(puData)) 184 186 { 185 uint8_t *puData; 186 187 puData = (uint8_t *)RTMemAllocZ(Packet.cbData); 188 if (RT_VALID_PTR(puData)) 187 /* Add generic header to the beginning of the output buffer 188 * and receive the rest of the data into it. */ 189 memcpy(puData, &Packet, sizeof(Packet)); 190 191 rc = RTLocalIpcSessionRead(hSession, puData + sizeof(Packet), 192 Packet.cbData - sizeof(Packet), NULL); 193 if (RT_SUCCESS(rc)) 189 194 { 190 /* Add generic header to the beginning of the output buffer 191 * and receive the rest of the data into it. */ 192 memcpy(puData, &Packet, sizeof(Packet)); 193 194 rc = RTLocalIpcSessionRead(hSession, puData + sizeof(Packet), 195 Packet.cbData - sizeof(Packet), &cbRead); 196 if (RT_SUCCESS(rc)) 195 if (vbcl::ipc::packet_verify((vbcl::ipc::packet_t *)puData, Packet.cbData)) 197 196 { 198 if (cbRead == (Packet.cbData - sizeof(Packet))) 199 { 200 if (vbcl::ipc::packet_verify((vbcl::ipc::packet_t *)puData, Packet.cbData)) 201 { 202 /* Now return received data to the caller. */ 203 *ppvData = puData; 204 } 205 else 206 rc = VERR_NOT_EQUAL; 207 } 208 else 209 rc = VERR_BUFFER_UNDERFLOW; 197 /* Now return received data to the caller. */ 198 *ppvData = puData; 210 199 } 211 212 if (RT_FAILURE(rc)) 213 RTMemFree(puData); 200 else 201 rc = VERR_NOT_EQUAL; 214 202 } 215 else 216 rc = VERR_NO_MEMORY; 203 204 if (RT_FAILURE(rc)) 205 RTMemFree(puData); 217 206 } 218 207 else 219 rc = VERR_ INVALID_PARAMETER;208 rc = VERR_NO_MEMORY; 220 209 } 210 else 211 rc = VERR_INVALID_PARAMETER; 221 212 222 213 if (RT_FAILURE(rc))
Note:
See TracChangeset
for help on using the changeset viewer.