You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@zookeeper.apache.org by "Gowrima (Jira)" <ji...@apache.org> on 2026/10/14 17:24:00 UTC
[jira] [Commented] (ZOOKEEPER-5007) Memory Leak in zookeeper_init_ssl
[ https://issues.apache.org/jira/browse/ZOOKEEPER-5007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18127206#comment-18127206 ]
Gowrima commented on ZOOKEEPER-5007:
------------------------------------
The memory allocated during strdup is freed in zookeeper_close(). This is a duplicate of https://issues.apache.org/jira/browse/ZOOKEEPER-4020.
> Memory Leak in zookeeper_init_ssl
> ---------------------------------
>
> Key: ZOOKEEPER-5007
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-5007
> Project: ZooKeeper
> Issue Type: Bug
> Components: c client
> Affects Versions: 3.9.4
> Reporter: Cyl
> Priority: Major
> Attachments: ssl_leak_poc.c
>
>
> The function {{zookeeper_init_ssl}} in {{zookeeper-client/zookeeper-client-c/src/zookeeper.c}} allocates memory for the certificate string using {{strdup}} but fails to free it before returning.
> File: {{zookeeper-client/zookeeper-client-c/src/zookeeper.c}} Function: {{zookeeper_init_ssl}} (around line 1450)
> {code:java}
> zhandle_t *zookeeper_init_ssl(const char *host, const char *cert, watcher_fn watcher,
> int recv_timeout, const clientid_t *clientid, void *context, int flags)
> {
> zcert_t zcert;
> zcert.certstr = strdup(cert); // <--- LEAK: Allocated here
> zcert.ca = strtok(zcert.certstr, ",");
> zcert.cert = strtok(NULL, ",");
> zcert.key = strtok(NULL, ",");
> zcert.passwd = strtok(NULL, ",");
> return zookeeper_init_internal(host, watcher, recv_timeout, clientid, context, flags, NULL, &zcert, NULL);
> // <--- LEAK: zcert.certstr is never freed
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)