]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Fix handling an optional invalid cipher at the end of data-ciphers
authorArne Schwabe <arne@rfc2549.org>
Mon, 6 Dec 2021 15:08:52 +0000 (16:08 +0100)
committerGert Doering <gert@greenie.muc.de>
Fri, 11 Nov 2022 13:38:10 +0000 (14:38 +0100)
If an optional cipher was found at the end of --data-cipher that was
not available, it would reset the error and allow non optional ciphers
to be ignored.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211206150852.3142891-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/search?l=mid&q=20211206150852.3142891-1-arne@rfc2549.org
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 868433857fbf8d71515ac0ffecb98eae893515dc)

src/openvpn/ssl_ncp.c
tests/unit_tests/openvpn/test_ncp.c

index de7efa40793a90a01028e7282c73d9b0d2890d98..4ab39a53903ff3b70d461e6c583d69dae8851c90 100644 (file)
@@ -133,7 +133,7 @@ mutate_ncp_cipher_list(const char *list, struct gc_arena *gc)
         {
             const char* optstr = optional ? "optional ": "";
             msg(M_WARN, "Unsupported %scipher in --data-ciphers: %s", optstr, token);
-            error_found = !optional;
+            error_found = error_found || !optional;
         }
         else
         {
index 134a58ab6f7e0a8ad4bc2bf6d684243761be2a51..6e1e50a47cb8a51f86fa9179c2550b2246d5ffb7 100644 (file)
@@ -85,6 +85,9 @@ test_check_ncp_ciphers_list(void **state)
     /* All unsupported should still yield an empty list */
     assert_ptr_equal(mutate_ncp_cipher_list("?kugelfisch:?grasshopper", &gc), NULL);
 
+    /* If the last is optional, previous invalid ciphers should be ignored */
+    assert_ptr_equal(mutate_ncp_cipher_list("Vollbit:Littlebit:AES-256-CBC:BF-CBC:?nixbit", &gc), NULL);
+
     /* For testing that with OpenSSL 1.1.0+ that also accepts ciphers in
      * a different spelling the normalised cipher output is the same */
     bool have_chacha_mixed_case = cipher_kt_get("ChaCha20-Poly1305");