Browse Source

rename pos variables to offset to prevent variable shadowing in the amalgamation

Julius Pfrommer 8 years ago
parent
commit
026692c2a9

+ 39 - 39
src/server/ua_server_binary.c

@@ -17,10 +17,10 @@ static void init_response_header(const UA_RequestHeader *p, UA_ResponseHeader *r
 }
 
 static void
-sendError(UA_SecureChannel *channel, const UA_ByteString *msg, size_t pos, const UA_DataType *responseType,
+sendError(UA_SecureChannel *channel, const UA_ByteString *msg, size_t offset, const UA_DataType *responseType,
           UA_UInt32 requestId, UA_StatusCode error) {
     UA_RequestHeader requestHeader;
-    UA_StatusCode retval = UA_RequestHeader_decodeBinary(msg, &pos, &requestHeader);
+    UA_StatusCode retval = UA_RequestHeader_decodeBinary(msg, &offset, &requestHeader);
     if(retval != UA_STATUSCODE_GOOD)
         return;
     void *response = UA_alloca(responseType->memSize);
@@ -37,17 +37,17 @@ sendError(UA_SecureChannel *channel, const UA_ByteString *msg, size_t pos, const
    or UA_BYTESTRING_NULL */
 static UA_ByteString processChunk(UA_SecureChannel *channel, UA_Server *server,
                                   const UA_TcpMessageHeader *messageHeader, UA_UInt32 requestId,
-                                  const UA_ByteString *msg, size_t pos, size_t chunksize,
+                                  const UA_ByteString *msg, size_t offset, size_t chunksize,
                                   UA_Boolean *deleteRequest) {
     UA_ByteString bytes = UA_BYTESTRING_NULL;
     switch(messageHeader->messageTypeAndChunkType & 0xff000000) {
     case UA_CHUNKTYPE_INTERMEDIATE:
         UA_LOG_TRACE_CHANNEL(server->config.logger, channel, "Chunk message");
-        UA_SecureChannel_appendChunk(channel, requestId, msg, pos, chunksize);
+        UA_SecureChannel_appendChunk(channel, requestId, msg, offset, chunksize);
         break;
     case UA_CHUNKTYPE_FINAL:
         UA_LOG_TRACE_CHANNEL(server->config.logger, channel, "Final chunk message");
-        bytes = UA_SecureChannel_finalizeChunk(channel, requestId, msg, pos, chunksize, deleteRequest);
+        bytes = UA_SecureChannel_finalizeChunk(channel, requestId, msg, offset, chunksize, deleteRequest);
         break;
     case UA_CHUNKTYPE_ABORT:
         UA_LOG_INFO_CHANNEL(server->config.logger, channel, "Chunk aborted");
@@ -221,9 +221,9 @@ getServicePointers(UA_UInt32 requestTypeId, const UA_DataType **requestType,
 /*************************/
 
 /* HEL -> Open up the connection */
-static void processHEL(UA_Connection *connection, const UA_ByteString *msg, size_t *pos) {
+static void processHEL(UA_Connection *connection, const UA_ByteString *msg, size_t *offset) {
     UA_TcpHelloMessage helloMessage;
-    if(UA_TcpHelloMessage_decodeBinary(msg, pos, &helloMessage) != UA_STATUSCODE_GOOD) {
+    if(UA_TcpHelloMessage_decodeBinary(msg, offset, &helloMessage) != UA_STATUSCODE_GOOD) {
         connection->close(connection);
         return;
     }
@@ -265,14 +265,14 @@ static void processHEL(UA_Connection *connection, const UA_ByteString *msg, size
 }
 
 /* OPN -> Open up/renew the securechannel */
-static void processOPN(UA_Connection *connection, UA_Server *server, const UA_ByteString *msg, size_t *pos) {
+static void processOPN(UA_Connection *connection, UA_Server *server, const UA_ByteString *msg, size_t *offset) {
     if(connection->state != UA_CONNECTION_ESTABLISHED) {
         connection->close(connection);
         return;
     }
 
     UA_UInt32 channelId;
-    UA_StatusCode retval = UA_UInt32_decodeBinary(msg, pos, &channelId);
+    UA_StatusCode retval = UA_UInt32_decodeBinary(msg, offset, &channelId);
 
     /* Opening up a channel with a channelid already set */
     if(!connection->channel && channelId != 0)
@@ -282,16 +282,16 @@ static void processOPN(UA_Connection *connection, UA_Server *server, const UA_By
         retval |= UA_STATUSCODE_BADREQUESTTYPEINVALID;
 
     UA_AsymmetricAlgorithmSecurityHeader asymHeader;
-    retval |= UA_AsymmetricAlgorithmSecurityHeader_decodeBinary(msg, pos, &asymHeader);
+    retval |= UA_AsymmetricAlgorithmSecurityHeader_decodeBinary(msg, offset, &asymHeader);
 
     UA_SequenceHeader seqHeader;
-    retval |= UA_SequenceHeader_decodeBinary(msg, pos, &seqHeader);
+    retval |= UA_SequenceHeader_decodeBinary(msg, offset, &seqHeader);
 
     UA_NodeId requestType;
-    retval |= UA_NodeId_decodeBinary(msg, pos, &requestType);
+    retval |= UA_NodeId_decodeBinary(msg, offset, &requestType);
 
     UA_OpenSecureChannelRequest r;
-    retval |= UA_OpenSecureChannelRequest_decodeBinary(msg, pos, &r);
+    retval |= UA_OpenSecureChannelRequest_decodeBinary(msg, offset, &r);
 
     if(retval != UA_STATUSCODE_GOOD || requestType.identifier.numeric != 446) {
         UA_AsymmetricAlgorithmSecurityHeader_deleteMembers(&asymHeader);
@@ -370,16 +370,16 @@ static void
 processRequest(UA_SecureChannel *channel, UA_Server *server, UA_UInt32 requestId, const UA_ByteString *msg) {
     /* At 0, the nodeid starts... */
     size_t ppos = 0;
-    size_t *pos = &ppos;
+    size_t *offset = &ppos;
 
     /* Decode the nodeid */
     UA_NodeId requestTypeId;
-    UA_StatusCode retval = UA_NodeId_decodeBinary(msg, pos, &requestTypeId);
+    UA_StatusCode retval = UA_NodeId_decodeBinary(msg, offset, &requestTypeId);
     if(retval != UA_STATUSCODE_GOOD)
         return;
 
     /* Store the start-position of the request */
-    size_t requestPos = *pos;
+    size_t requestPos = *offset;
 
     /* Test if the service type nodeid has the right format */
     if(requestTypeId.identifierType != UA_NODEIDTYPE_NUMERIC ||
@@ -416,7 +416,7 @@ processRequest(UA_SecureChannel *channel, UA_Server *server, UA_UInt32 requestId
     /* Decode the request */
     void *request = UA_alloca(requestType->memSize);
     UA_RequestHeader *requestHeader = (UA_RequestHeader*)request;
-    retval = UA_decodeBinary(msg, pos, request, requestType);
+    retval = UA_decodeBinary(msg, offset, request, requestType);
     if(retval != UA_STATUSCODE_GOOD) {
         UA_LOG_DEBUG_CHANNEL(server->config.logger, channel, "Could not decode the request");
         sendError(channel, msg, requestPos, responseType, requestId, retval);
@@ -516,14 +516,14 @@ processRequest(UA_SecureChannel *channel, UA_Server *server, UA_UInt32 requestId
 /* MSG -> Normal request */
 static void
 processMSG(UA_Connection *connection, UA_Server *server, const UA_TcpMessageHeader *messageHeader,
-           const UA_ByteString *msg, size_t *pos) {
+           const UA_ByteString *msg, size_t *offset) {
     /* Decode the header */
     UA_UInt32 channelId = 0;
     UA_UInt32 tokenId = 0;
     UA_SequenceHeader sequenceHeader;
-    UA_StatusCode retval = UA_UInt32_decodeBinary(msg, pos, &channelId);
-    retval |= UA_UInt32_decodeBinary(msg, pos, &tokenId);
-    retval |= UA_SequenceHeader_decodeBinary(msg, pos, &sequenceHeader);
+    UA_StatusCode retval = UA_UInt32_decodeBinary(msg, offset, &channelId);
+    retval |= UA_UInt32_decodeBinary(msg, offset, &tokenId);
+    retval |= UA_SequenceHeader_decodeBinary(msg, offset, &sequenceHeader);
     if(retval != UA_STATUSCODE_GOOD)
         return;
 
@@ -554,7 +554,7 @@ processMSG(UA_Connection *connection, UA_Server *server, const UA_TcpMessageHead
             UA_LOG_INFO_CHANNEL(server->config.logger, channel,
                                 "The sequence number was not increased by one. Got %i, expected %i",
                                 sequenceHeader.sequenceNumber, channel->receiveSequenceNumber + 1);
-            sendError(channel, msg, *pos, &UA_TYPES[UA_TYPES_SERVICEFAULT],
+            sendError(channel, msg, *offset, &UA_TYPES[UA_TYPES_SERVICEFAULT],
                       sequenceHeader.requestId, UA_STATUSCODE_BADSECURITYCHECKSFAILED);
             return;
         }
@@ -576,8 +576,8 @@ processMSG(UA_Connection *connection, UA_Server *server, const UA_TcpMessageHead
     /* Process chunk to get complete request */
     UA_Boolean deleteRequest = false;
     UA_ByteString request = processChunk(channel, server, messageHeader, sequenceHeader.requestId,
-                                         msg, *pos, messageHeader->messageSize - 24, &deleteRequest);
-    *pos += (messageHeader->messageSize - 24);
+                                         msg, *offset, messageHeader->messageSize - 24, &deleteRequest);
+    *offset += (messageHeader->messageSize - 24);
     if(request.length > 0) {
         /* Process the request */
         processRequest(channel, server, sequenceHeader.requestId, &request);
@@ -592,13 +592,13 @@ processMSG(UA_Connection *connection, UA_Server *server, const UA_TcpMessageHead
 
 /* CLO -> Close the secure channel */
 static void
-processCLO(UA_Connection *connection, UA_Server *server, const UA_ByteString *msg, size_t *pos) {
+processCLO(UA_Connection *connection, UA_Server *server, const UA_ByteString *msg, size_t *offset) {
     UA_UInt32 channelId;
     UA_UInt32 tokenId = 0;
     UA_SequenceHeader sequenceHeader;
-    UA_StatusCode retval = UA_UInt32_decodeBinary(msg, pos, &channelId);
-    retval |= UA_UInt32_decodeBinary(msg, pos, &tokenId);
-    retval |= UA_SequenceHeader_decodeBinary(msg, pos, &sequenceHeader);
+    UA_StatusCode retval = UA_UInt32_decodeBinary(msg, offset, &channelId);
+    retval |= UA_UInt32_decodeBinary(msg, offset, &tokenId);
+    retval |= UA_SequenceHeader_decodeBinary(msg, offset, &sequenceHeader);
     if(retval != UA_STATUSCODE_GOOD)
         return;
 
@@ -617,11 +617,11 @@ processCLO(UA_Connection *connection, UA_Server *server, const UA_ByteString *ms
  * you have to free it youself. use of connection->getSendBuffer() and
  * connection->send() to answer Message */
 void UA_Server_processBinaryMessage(UA_Server *server, UA_Connection *connection, const UA_ByteString *msg) {
-    size_t pos = 0;
+    size_t offset= 0;
     UA_TcpMessageHeader tcpMessageHeader;
     do {
         /* Decode the message header */
-        UA_StatusCode retval = UA_TcpMessageHeader_decodeBinary(msg, &pos, &tcpMessageHeader);
+        UA_StatusCode retval = UA_TcpMessageHeader_decodeBinary(msg, &offset, &tcpMessageHeader);
         if(retval != UA_STATUSCODE_GOOD) {
             UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_NETWORK,
                         "Decoding of message header failed on Connection %i", connection->sockfd);
@@ -636,18 +636,18 @@ void UA_Server_processBinaryMessage(UA_Server *server, UA_Connection *connection
         }
 
         /* Set the expected position after processing the chunk */
-        size_t targetpos = pos - 8 + tcpMessageHeader.messageSize;
+        size_t targetpos = offset - 8 + tcpMessageHeader.messageSize;
 
         /* Process the message */
         switch(tcpMessageHeader.messageTypeAndChunkType & 0x00ffffff) {
         case UA_MESSAGETYPE_HEL:
             UA_LOG_TRACE(server->config.logger, UA_LOGCATEGORY_NETWORK, "Connection %i | Process a HEL", connection->sockfd);
-            processHEL(connection, msg, &pos);
+            processHEL(connection, msg, &offset);
             break;
 
         case UA_MESSAGETYPE_OPN:
             UA_LOG_TRACE(server->config.logger, UA_LOGCATEGORY_NETWORK, "Connection %i | Process a OPN", connection->sockfd);
-            processOPN(connection, server, msg, &pos);
+            processOPN(connection, server, msg, &offset);
             break;
 
         case UA_MESSAGETYPE_MSG:
@@ -660,12 +660,12 @@ void UA_Server_processBinaryMessage(UA_Server *server, UA_Connection *connection
             }
 #endif
             UA_LOG_TRACE(server->config.logger, UA_LOGCATEGORY_NETWORK, "Connection %i | Process a MSG", connection->sockfd);
-            processMSG(connection, server, &tcpMessageHeader, msg, &pos);
+            processMSG(connection, server, &tcpMessageHeader, msg, &offset);
             break;
 
         case UA_MESSAGETYPE_CLO:
             UA_LOG_TRACE(server->config.logger, UA_LOGCATEGORY_NETWORK, "Connection %i | Process a CLO", connection->sockfd);
-            processCLO(connection, server, msg, &pos);
+            processCLO(connection, server, msg, &offset);
             return;
 
         default:
@@ -673,11 +673,11 @@ void UA_Server_processBinaryMessage(UA_Server *server, UA_Connection *connection
         }
 
         /* Loop to process the next message in the stream */
-        if(pos != targetpos) {
+        if(offset != targetpos) {
             UA_LOG_DEBUG(server->config.logger, UA_LOGCATEGORY_NETWORK, "Connection %i | Message was not entirely processed. "
-                         "Skip from position %i to position %i; message length is %i", connection->sockfd, pos, targetpos,
+                         "Skip from position %i to position %i; message length is %i", connection->sockfd, offset, targetpos,
                          msg->length);
-            pos = targetpos;
+            offset = targetpos;
         }
-    } while(msg->length > pos);
+    } while(msg->length > offset);
 }

+ 6 - 6
src/server/ua_services_attribute.c

@@ -51,7 +51,7 @@ UA_StatusCode parse_numericrange(const UA_String *str, UA_NumericRange *range) {
     size_t dimensionsMax = 0;
     struct UA_NumericRangeDimension *dimensions = NULL;
     UA_StatusCode retval = UA_STATUSCODE_GOOD;
-    size_t pos = 0;
+    size_t offset = 0;
     while(true) {
         /* alloc dimensions */
         if(idx >= dimensionsMax) {
@@ -66,23 +66,23 @@ UA_StatusCode parse_numericrange(const UA_String *str, UA_NumericRange *range) {
         }
 
         /* read the dimension */
-        size_t progress = readDimension(&str->data[pos], str->length - pos, &dimensions[idx]);
+        size_t progress = readDimension(&str->data[offset], str->length - offset, &dimensions[idx]);
         if(progress == 0) {
             retval = UA_STATUSCODE_BADINDEXRANGEINVALID;
             break;
         }
-        pos += progress;
+        offset += progress;
         idx++;
 
         /* loop into the next dimension */
-        if(pos >= str->length)
+        if(offset >= str->length)
             break;
 
-        if(str->data[pos] != ',') {
+        if(str->data[offset] != ',') {
             retval = UA_STATUSCODE_BADINDEXRANGEINVALID;
             break;
         }
-        pos++;
+        offset++;
     }
 
     if(retval == UA_STATUSCODE_GOOD && idx > 0) {

+ 18 - 18
src/ua_connection.c

@@ -52,34 +52,34 @@ UA_Connection_completeMessages(UA_Connection *connection, UA_ByteString * UA_RES
         *realloced = true;
     }
 
-    /* the while loop sets pos to the first element after the last complete message. if a message
+    /* the while loop sets offset to the first element after the last complete message. if a message
        contains garbage, the buffer length is set to contain only the "good" messages before. */
-    size_t pos = 0;
+    size_t offset = 0;
     size_t delete_at = current->length-1; // garbled message after this point
-    while(current->length - pos >= 16) {
-        UA_UInt32 msgtype = (UA_UInt32)current->data[pos] +
-            ((UA_UInt32)current->data[pos+1] << 8) +
-            ((UA_UInt32)current->data[pos+2] << 16);
+    while(current->length - offset >= 16) {
+        UA_UInt32 msgtype = (UA_UInt32)current->data[offset] +
+            ((UA_UInt32)current->data[offset+1] << 8) +
+            ((UA_UInt32)current->data[offset+2] << 16);
         if(msgtype != ('M' + ('S' << 8) + ('G' << 16)) &&
            msgtype != ('O' + ('P' << 8) + ('N' << 16)) &&
            msgtype != ('H' + ('E' << 8) + ('L' << 16)) &&
            msgtype != ('A' + ('C' << 8) + ('K' << 16)) &&
            msgtype != ('C' + ('L' << 8) + ('O' << 16))) {
             /* the message type is not recognized */
-            delete_at = pos; // throw the remaining message away
+            delete_at = offset; // throw the remaining message away
             break;
         }
         UA_UInt32 length = 0;
-        size_t length_pos = pos + 4;
+        size_t length_pos = offset + 4;
         UA_StatusCode retval = UA_UInt32_decodeBinary(current, &length_pos, &length);
         if(retval != UA_STATUSCODE_GOOD || length < 16 || length > connection->localConf.recvBufferSize) {
             /* the message size is not allowed. throw the remaining bytestring away */
-            delete_at = pos;
+            delete_at = offset;
             break;
         }
-        if(length + pos > current->length)
+        if(length + offset > current->length)
             break; /* the message is incomplete. keep the beginning */
-        pos += length;
+        offset += length;
     }
 
     /* throw the message away */
@@ -93,19 +93,19 @@ UA_Connection_completeMessages(UA_Connection *connection, UA_ByteString * UA_RES
     }
 
     /* no complete message at all */
-    if(pos == 0) {
+    if(offset == 0) {
         if(!*realloced) {
             /* store the buffer in the connection */
             UA_ByteString_copy(current, &connection->incompleteMessage);
             connection->releaseRecvBuffer(connection, message);
             *realloced = true;
-        } 
+        }
         return UA_STATUSCODE_GOOD;
     }
 
     /* there remains an incomplete message at the end */
-    if(current->length != pos) {
-        UA_Byte *data = UA_malloc(current->length - pos);
+    if(current->length != offset) {
+        UA_Byte *data = UA_malloc(current->length - offset);
         if(!data) {
             UA_ByteString_deleteMembers(&connection->incompleteMessage);
             if(!*realloced) {
@@ -114,9 +114,9 @@ UA_Connection_completeMessages(UA_Connection *connection, UA_ByteString * UA_RES
             }
             return UA_STATUSCODE_BADOUTOFMEMORY;
         }
-        size_t newlength = current->length - pos;
-        memcpy(data, &current->data[pos], newlength);
-        current->length = pos;
+        size_t newlength = current->length - offset;
+        memcpy(data, &current->data[offset], newlength);
+        current->length = offset;
         if(*realloced)
             *message = *current;
         connection->incompleteMessage.data = data;

+ 17 - 13
src/ua_securechannel.c

@@ -4,6 +4,7 @@
 #include "ua_types_encoding_binary.h"
 #include "ua_types_generated_encoding_binary.h"
 #include "ua_transport_generated_encoding_binary.h"
+#include <stdio.h>
 
 #define UA_SECURE_MESSAGE_HEADER_LENGTH 24
 
@@ -138,11 +139,9 @@ UA_SecureChannel_sendChunk(UA_ChunkInfo *ci, UA_ByteString *dst, size_t offset)
     dst->data = &dst->data[-UA_SECURE_MESSAGE_HEADER_LENGTH];
     dst->length += UA_SECURE_MESSAGE_HEADER_LENGTH;
     offset += UA_SECURE_MESSAGE_HEADER_LENGTH;
-    ci->messageSizeSoFar += offset;
 
-    UA_Boolean chunkedMsg = (ci->chunksSoFar > 0 || ci->final == false);
-    UA_Boolean abortMsg = ((++ci->chunksSoFar >= connection->remoteConf.maxChunkCount ||
-                            ci->messageSizeSoFar > connection->remoteConf.maxMessageSize)) && chunkedMsg;
+    UA_Boolean abortMsg = (ci->abort || ++ci->chunksSoFar > connection->remoteConf.maxChunkCount ||
+                           ci->messageSizeSoFar + offset > connection->remoteConf.maxMessageSize);
 
     /* Prepare the chunk headers */
     UA_SecureConversationMessageHeader respHeader;
@@ -163,6 +162,9 @@ UA_SecureChannel_sendChunk(UA_ChunkInfo *ci, UA_ByteString *dst, size_t offset)
         UA_String_encodeBinary(&errorMsg,dst,&offset);
     }
     respHeader.messageHeader.messageSize = (UA_UInt32)offset;
+    ci->messageSizeSoFar += offset;
+
+    printf("send chunk of length %i\n", respHeader.messageHeader.messageSize);
 
     UA_SymmetricAlgorithmSecurityHeader symSecHeader;
     symSecHeader.tokenId = channel->securityToken.tokenId;
@@ -194,6 +196,8 @@ UA_SecureChannel_sendChunk(UA_ChunkInfo *ci, UA_ByteString *dst, size_t offset)
         dst->data = &dst->data[UA_SECURE_MESSAGE_HEADER_LENGTH];
         dst->length = connection->localConf.sendBufferSize - UA_SECURE_MESSAGE_HEADER_LENGTH;
     }
+    if(ci->abort)
+        return UA_STATUSCODE_BADTCPMESSAGETOOLARGE;
     return UA_STATUSCODE_GOOD;
 }
 
@@ -255,21 +259,21 @@ UA_SecureChannel_sendBinaryMessage(UA_SecureChannel *channel, UA_UInt32 requestI
 
 /* assume that chunklength fits */
 static void appendChunk(struct ChunkEntry *ch, const UA_ByteString *msg,
-                        size_t pos, size_t chunklength) {
+                        size_t offset, size_t chunklength) {
     UA_Byte* new_bytes = UA_realloc(ch->bytes.data, ch->bytes.length + chunklength);
     if(!new_bytes) {
         UA_ByteString_deleteMembers(&ch->bytes);
         return;
     }
     ch->bytes.data = new_bytes;
-    memcpy(&ch->bytes.data[ch->bytes.length], &msg->data[pos], chunklength);
+    memcpy(&ch->bytes.data[ch->bytes.length], &msg->data[offset], chunklength);
     ch->bytes.length += chunklength;
 }
 
 void UA_SecureChannel_appendChunk(UA_SecureChannel *channel, UA_UInt32 requestId,
-                                  const UA_ByteString *msg, size_t pos, size_t chunklength) {
+                                  const UA_ByteString *msg, size_t offset, size_t chunklength) {
     /* Check if the chunk fits into the message */
-    if(msg->length - pos < chunklength) {
+    if(msg->length - offset < chunklength) {
         UA_SecureChannel_removeChunk(channel, requestId); /* can't process all chunks for that request */
         return;
     }
@@ -289,13 +293,13 @@ void UA_SecureChannel_appendChunk(UA_SecureChannel *channel, UA_UInt32 requestId
         LIST_INSERT_HEAD(&channel->chunks, ch, pointers);
     }
 
-    appendChunk(ch, msg, pos, chunklength);
+    appendChunk(ch, msg, offset, chunklength);
 }
 
 UA_ByteString UA_SecureChannel_finalizeChunk(UA_SecureChannel *channel, UA_UInt32 requestId,
-                                             const UA_ByteString *msg, size_t pos, size_t chunklength,
+                                             const UA_ByteString *msg, size_t offset, size_t chunklength,
                                              UA_Boolean *deleteChunk) {
-    if(msg->length - pos < chunklength) {
+    if(msg->length - offset < chunklength) {
         UA_SecureChannel_removeChunk(channel, requestId); /* can't process all chunks for that request */
         return UA_BYTESTRING_NULL;
     }
@@ -310,10 +314,10 @@ UA_ByteString UA_SecureChannel_finalizeChunk(UA_SecureChannel *channel, UA_UInt3
     if(!ch) {
         *deleteChunk = false;
         bytes.length = chunklength;
-        bytes.data = msg->data + pos;
+        bytes.data = msg->data + offset;
     } else {
         *deleteChunk = true;
-        appendChunk(ch, msg, pos, chunklength);
+        appendChunk(ch, msg, offset, chunklength);
         bytes = ch->bytes;
         LIST_REMOVE(ch, pointers);
         UA_free(ch);

+ 3 - 3
src/ua_securechannel.h

@@ -64,15 +64,15 @@ void UA_SecureChannel_revolveTokens(UA_SecureChannel *channel);
 /**
  * Chunking
  * -------- */
-/* Pos is initially set to the beginning of the chunk content. chunklength is
+/* Offset is initially set to the beginning of the chunk content. chunklength is
    the length of the decoded chunk content (minus header, padding, etc.) */
 void UA_SecureChannel_appendChunk(UA_SecureChannel *channel, UA_UInt32 requestId,
-                                  const UA_ByteString *msg, size_t pos, size_t chunklength);
+                                  const UA_ByteString *msg, size_t offset, size_t chunklength);
 
 /* deleteChunk indicates if the returned bytestring was copied off the network
    buffer (and needs to be freed) or points into the msg */
 UA_ByteString UA_SecureChannel_finalizeChunk(UA_SecureChannel *channel, UA_UInt32 requestId,
-                                             const UA_ByteString *msg, size_t pos, size_t chunklength,
+                                             const UA_ByteString *msg, size_t offset, size_t chunklength,
                                              UA_Boolean *deleteChunk);
 
 void UA_SecureChannel_removeChunk(UA_SecureChannel *channel, UA_UInt32 requestId);