You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2018/02/07 23:04:19 UTC

[GitHub] merlimat commented on a change in pull request #1195: Ensure the checksum is not stripped after validation in the broker

merlimat commented on a change in pull request #1195: Ensure the checksum is not stripped after validation in the broker
URL: https://github.com/apache/incubator-pulsar/pull/1195#discussion_r166785499
 
 

 ##########
 File path: pulsar-client-cpp/lib/ClientConnection.cc
 ##########
 @@ -518,13 +520,16 @@ void ClientConnection::processIncomingBuffer() {
     readNextCommand();
 }
 
-bool ClientConnection::verifyChecksum(SharedBuffer& incomingBuffer_, proto::BaseCommand& incomingCmd_) {
+bool ClientConnection::verifyChecksum(SharedBuffer& incomingBuffer_, uint32_t& remainingBytes, proto::BaseCommand& incomingCmd_) {
     int readerIndex = incomingBuffer_.readerIndex();
     bool isChecksumValid = true;
+
     if (incomingBuffer_.readUnsignedShort() == Commands::magicCrc32c) {
         uint32_t storedChecksum = incomingBuffer_.readUnsignedInt();
+        remainingBytes -= (2 + 4) /* subtract size of checksum itself */;
+
         // compute metadata-payload checksum
-        int metadataPayloadSize = incomingBuffer_.readableBytes();
 
 Review comment:
   This was not what was failing here, but the problem is that the `incomingBuffer_` is not a slice containing only the current frame (like we have with Netty). In this case it can contain data after the current frame, so have to "manually" limit ourselves to no exceed the frame.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services