Skip to content

Commit

Permalink
Merge pull request #18230 from richardkchapman/HPCC-31139
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 [email protected]
Reviewed-by: Gavin Halliday <[email protected]>
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Jan 17, 2024
2 parents 71d4b75 + 695be14 commit a786733
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions roxie/udplib/udptrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,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);
data_socket->write(encryptBuffer.toByteArray(), encryptBuffer.length());
}
Expand Down
2 changes: 1 addition & 1 deletion testing/unittests/jlibtests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3779,7 +3779,7 @@ class JLibOpensslAESTest : public CppUnit::TestFixture
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31
};
constexpr const char * prefix = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
constexpr unsigned lenPrefix = strlen(prefix);
unsigned lenPrefix = strlen(prefix);

MemoryBuffer ciphertext1, ciphertext2, decrypted1, decrypted2;

Expand Down

0 comments on commit a786733

Please sign in to comment.