Pārlūkot izejas kodu

Fixed code analyze fix and reserve 1 more byte for padding.

Jonas Green 5 gadi atpakaļ
vecāks
revīzija
e0eb2a099a
1 mainītis faili ar 2 papildinājumiem un 2 dzēšanām
  1. 2 2
      src/ua_securechannel.c

+ 2 - 2
src/ua_securechannel.c

@@ -599,7 +599,7 @@ setBufPos(UA_MessageContext *mc) {
         /* PaddingSize and ExtraPaddingSize fields */
         size_t encryptionBlockSize = securityPolicy->symmetricModule.cryptoModule.encryptionAlgorithm.
             getLocalBlockSize(securityPolicy, channel->channelContext );
-        mc->buf_end -= 1 + (encryptionBlockSize >> 8) ? 1 : 0;
+        mc->buf_end -= 1 + ((encryptionBlockSize >> 8) ? 1 : 0);
 
         /* Reduce the message body size with the remainder of the operation
          * maxEncryptedDataSize modulo EncryptionBlockSize to get a whole
@@ -607,7 +607,7 @@ setBufPos(UA_MessageContext *mc) {
          * padding (1 <= paddingSize <= encryptionBlockSize).
          */
         size_t maxEncryptDataSize = mc->messageBuffer.length-UA_SECURE_CONVERSATION_MESSAGE_HEADER_LENGTH-UA_SYMMETRIC_ALG_SECURITY_HEADER_LENGTH;
-        mc->buf_end -= (maxEncryptDataSize % encryptionBlockSize);
+        mc->buf_end -= (maxEncryptDataSize % encryptionBlockSize) + 1;
     }
 }