Fix CVE-2017-6891 in minitasn1 code
[platform/upstream/gnutls.git] / lib / crypto-selftests.c
index 449747f..636930f 100644 (file)
@@ -271,7 +271,7 @@ static int test_cipher(gnutls_cipher_algorithm_t cipher,
                                           vectors[i].plaintext_size,
                                           tmp, sizeof(tmp));
                if (ret < 0)
-                       return 0;
+                       return gnutls_assert_val(GNUTLS_E_SELF_TEST_ERROR);
 
                gnutls_cipher_deinit(hd);
 
@@ -281,6 +281,7 @@ static int test_cipher(gnutls_cipher_algorithm_t cipher,
                        _gnutls_debug_log("%s test vector %d failed!\n",
                                          gnutls_cipher_get_name(cipher),
                                          i);
+                       return gnutls_assert_val(GNUTLS_E_SELF_TEST_ERROR);
                }
        }
 
@@ -298,7 +299,8 @@ static int test_cipher(gnutls_cipher_algorithm_t cipher,
 
                ret =
                    gnutls_cipher_decrypt2(hd,
-                                          vectors[i].ciphertext, 16, tmp,
+                                          vectors[i].ciphertext, 
+                                          vectors[i].plaintext_size, tmp,
                                           sizeof(tmp));
                if (ret < 0) {
                        _gnutls_debug_log