I was looking for memleaks in the code and found
this one with cppcheck. Only an example, but no
need to leave this bug in it.
Also fix fortify problem in keying-material-exporter-demo
so I can actually test the compilation of the sample
plugins.
v2:
- remove unneccessary usages of snprintf, replace
with strncpy.
Change-Id: Ibd1b282afc4a28768be3f165f84ab60ca4d24a9b
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <
20230516093534.26384-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26668.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
if (!rl->name || !rl->value)
{
plugin_log(PLOG_ERR, MODULE, "malloc(return_list->xx) failed");
+ free(rl->name);
+ free(rl->value);
+ free(rl);
return OPENVPN_PLUGIN_FUNC_ERROR;
}
if (!rl->name || !rl->value)
{
plugin_log(PLOG_ERR, MODULE, "malloc(return_list->xx) failed");
+ free(rl->name);
+ free(rl->value);
+ free(rl);
return OPENVPN_PLUGIN_FUNC_ERROR;
}
if (!strncasecmp(objbuf, "CN", 2))
{
- snprintf(sess->user, sizeof(sess->user) - 1, (char *)buf);
+ strncpy(sess->user, (char *)buf, sizeof(sess->user) - 1);
}
OPENSSL_free(buf);
return OPENVPN_PLUGIN_FUNC_ERROR;
}
- snprintf(sess->key, sizeof(sess->key) - 1, "%s", key);
+ strncpy(sess->key, key, sizeof(sess->key) - 1);
ovpn_note("app session key: %s", sess->key);
switch (plugin->type)