PengZheng opened a new issue, #465:
URL: https://github.com/apache/celix/issues/465

   When reviewing #459, I found the following function problematic:
   
   ```C
   celix_status_t pubsubProtocol_decodeMetadata(void *data, size_t length, 
pubsub_protocol_message_t *message) {
       celix_status_t status = CELIX_SUCCESS;
   
       uint32_t nOfElements;
       size_t idx = pubsubProtocol_readInt(data, 0, 
message->header.convertEndianess, &nOfElements);
       unsigned char *netstring = data + idx;
       int netstringLen = length - idx;
   
       message->metadata.metadata = celix_properties_create();
       while (idx < length) {
           size_t outlen;
           status = pubsubProtocol_parseNetstring(netstring, netstringLen, 
&netstring, &outlen);
           if (status != CELIX_SUCCESS) {
               break;
           }
           char *key = calloc(outlen + 1, sizeof(char));
           memcpy(key, netstring, outlen);
           key[outlen] = '\0';
           netstring += outlen + 1; //FIXME: update netstringLen
           idx += outlen + 3;
   
           status = pubsubProtocol_parseNetstring(netstring, netstringLen, 
&netstring, &outlen);
           if (status != CELIX_SUCCESS) {
               break;
           }
           char *value = calloc(outlen + 1, sizeof(char));
           memcpy(value, netstring, outlen);
           value[outlen] = '\0';
           netstring += outlen + 1; //FIXME: update netstringLen
           idx += outlen + 3;
   
           celix_properties_setWithoutCopy(message->metadata.metadata, key, 
value); //FIXME: memory leaks for duplicated keys
       }
   
       return status;
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to