Skip to content

Commit

Permalink
Merge pull request #18236 from ghalliday/issue31139_812
Browse files Browse the repository at this point in the history
HPCC-31139 Length field gets corrupted in resent encrypted packets

Reviewed-by: Mark Kelly mark.kelly@lexisnexisrisk.com
Merged-by: Gavin Halliday <ghalliday@hpccsystems.com>
  • Loading branch information
ghalliday authored Jan 19, 2024
2 parents f884899 + 063a9ec commit c985142
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions roxie/udplib/udptrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,9 @@ class UdpReceiverEntry : public IUdpReceiverEntry
const char *data = buffer->data + sizeof(UdpPacketHeader);
const MemoryAttr &udpkey = getSecretUdpKey(true);
aesEncrypt(udpkey.get(), udpkey.length(), data, length, encryptBuffer);
header->length = encryptBuffer.length();
encryptBuffer.writeDirect(0, sizeof(UdpPacketHeader), header); // Only really need length updating
UdpPacketHeader newHeader;
newHeader.length = encryptBuffer.length();
encryptBuffer.writeDirect(offsetof(UdpPacketHeader, length), sizeof(newHeader.length), &newHeader.length); // Only need to update the length - rest is the same
assertex(encryptBuffer.length() <= DATA_PAYLOAD);
if (udpTraceLevel > 5)
DBGLOG("ENCRYPT: Writing %u bytes to data socket", encryptBuffer.length());
Expand Down

0 comments on commit c985142

Please sign in to comment.