You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@celix.apache.org by GitBox <gi...@apache.org> on 2023/01/05 12:51:37 UTC
[GitHub] [celix] PengZheng opened a new issue, #465: Memory corruption and leak in PSA
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: dev-unsubscribe@celix.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [celix] PengZheng closed issue #465: Memory corruption and leak in PSA
Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng closed issue #465: Memory corruption and leak in PSA
URL: https://github.com/apache/celix/issues/465
--
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: dev-unsubscribe@celix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org