Perform control stream encryption in-place

This commit is contained in:
Cameron Gutman committed 2026-10-19 01:10:46 -05:00
1 parent aeba988e0a
commit 342b106bbb
1 file changed
+1 -3
+1 -3
View File
@@ -703,7 +703,6 @@ static bool sendMessageEnet(short ptype, short paylen, const void* payload, uint
if (encryptedControlStream) {
PNVCTL_ENCRYPTED_PACKET_HEADER encPacket;
PNVCTL_ENET_PACKET_HEADER_V2 packet;
char tempBuffer[256];
enetPacket = enet_packet_create(NULL,
sizeof(*encPacket) + AES_GCM_TAG_LENGTH + sizeof(*packet) + paylen,
@@ -722,8 +721,7 @@ static bool sendMessageEnet(short ptype, short paylen, const void* payload, uint
encPacket->seq = currentEnetSequenceNumber++;
// Construct the plaintext data for encryption
LC_ASSERT(sizeof(*packet) + paylen < sizeof(tempBuffer));
packet = (PNVCTL_ENET_PACKET_HEADER_V2)tempBuffer;
packet = (PNVCTL_ENET_PACKET_HEADER_V2)(((unsigned char*)(encPacket + 1)) + AES_GCM_TAG_LENGTH);
packet->type = ptype;
packet->payloadLength = paylen;
memcpy(&packet[1], payload, paylen);