The NCP code does a strcmp(options->ciphername, ...) without first checking
whether options->ciphername is NULL. This could cause a crash when using
"--cipher none". This patch fixes that problem by ensuring that
options->ciphername (and options->authname) are never NULL. Ensuring that
options->ciphername is never null prevents us from having to write null
checks everywhere.
Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <
1475055231-1778-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg12576.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
{
bool aead_cipher = false;
+ ASSERT(ciphername);
+ ASSERT(authname);
+
CLEAR (*kt);
- if (ciphername)
+ if (strcmp (ciphername, "none") != 0)
{
kt->cipher = cipher_kt_get (translate_cipher_name_from_openvpn(ciphername));
kt->cipher_length = cipher_kt_key_size (kt->cipher);
if (warn)
msg (M_WARN, "******* WARNING *******: null cipher specified, no encryption will be used");
}
- if (authname)
+ if (strcmp (authname, "none") != 0)
{
if (!aead_cipher) { /* Ignore auth for AEAD ciphers */
kt->digest = md_kt_get (authname);
/* Initialize key_type for tls-auth with auth only */
CLEAR (c->c1.ks.tls_auth_key_type);
- if (options->authname)
+ if (!streq (options->authname, "none"))
{
c->c1.ks.tls_auth_key_type.digest = md_kt_get (options->authname);
c->c1.ks.tls_auth_key_type.hmac_length =
{
VERIFY_PERMISSION (OPT_P_GENERAL);
options->authname = p[1];
- if (streq (options->authname, "none"))
- {
- options->authname = NULL;
- }
}
else if (streq (p[0], "cipher") && p[1] && !p[2])
{
VERIFY_PERMISSION (OPT_P_NCP);
options->ciphername = p[1];
- if (streq (options->ciphername, "none"))
- {
- options->ciphername = NULL;
- }
}
else if (streq (p[0], "ncp-ciphers") && p[1] && !p[2])
{