]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Allow NULL argument in cipher_ctx_get_cipher_kt()
authorSteffan Karger <steffan@karger.me>
Sun, 7 Feb 2016 19:47:09 +0000 (20:47 +0100)
committerGert Doering <gert@greenie.muc.de>
Tue, 9 Feb 2016 06:51:14 +0000 (07:51 +0100)
Since otherwise we'll have to perform the check before each call.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1454874438-5081-2-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11079
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/crypto_backend.h
src/openvpn/crypto_openssl.c
src/openvpn/crypto_polarssl.c

index 4c1ce9fa6aa84302c2f1a9a04ac35d469a16fd36..1c23436485a03d1f1016d7906ddd6fdeba6a95fc 100644 (file)
@@ -308,12 +308,12 @@ int cipher_ctx_mode (const cipher_ctx_t *ctx);
 /**
  * Returns the static cipher parameters for this context.
  *
- * @param ctx          Cipher's context. May not be NULL.
+ * @param ctx          Cipher's context.
  *
- * @return             Static cipher parameters for the supplied context.
+ * @return             Static cipher parameters for the supplied context, or
+ *                     NULL if unable to determine cipher parameters.
  */
-const cipher_kt_t *cipher_ctx_get_cipher_kt (const cipher_ctx_t *ctx)
-  __attribute__((nonnull));
+const cipher_kt_t *cipher_ctx_get_cipher_kt (const cipher_ctx_t *ctx);
 
 /**
  * Resets the given cipher context, setting the IV to the specified value.
index 1d686623af8941e6f73ca3d5324fd520a8760dd3..7dabe5dfa4824dea66349411705d335297a188df 100644 (file)
@@ -585,7 +585,7 @@ cipher_ctx_mode (const EVP_CIPHER_CTX *ctx)
 const cipher_kt_t *
 cipher_ctx_get_cipher_kt (const cipher_ctx_t *ctx)
 {
-  return EVP_CIPHER_CTX_cipher(ctx);
+  return ctx ? EVP_CIPHER_CTX_cipher(ctx) : NULL;
 }
 
 
index 407a1769dac97a90a50570183d04824284807fa9..0e4c08839d592ee008bae816014e1551f46df0c4 100644 (file)
@@ -506,9 +506,7 @@ int cipher_ctx_mode (const cipher_context_t *ctx)
 const cipher_kt_t *
 cipher_ctx_get_cipher_kt (const cipher_ctx_t *ctx)
 {
-  ASSERT(NULL != ctx);
-
-  return ctx->cipher_info;
+  return ctx ? ctx->cipher_info : NULL;
 }
 
 int cipher_ctx_reset (cipher_context_t *ctx, uint8_t *iv_buf)