[openssl-commits] [openssl] master update
yang.yang at baishancloud.com
yang.yang at baishancloud.com
Mon Sep 3 12:36:53 UTC 2018
The branch master has been updated
via a7eeefeadc29f4290978ef1cdd800f3ea2850c10 (commit)
from 64a48fc7f0bc2d3ff587791b93a357bd98e1a5b8 (commit)
- Log -----------------------------------------------------------------
commit a7eeefeadc29f4290978ef1cdd800f3ea2850c10
Author: wzhang <zhangweikop at gmail.com>
Date: Wed Aug 8 01:04:18 2018 -0700
Fix the comment of PEM_read_bio_ex
Add one more unit test case
Reviewed-by: Richard Levitte <levitte at openssl.org>
Reviewed-by: Tim Hudson <tjh at openssl.org>
Reviewed-by: Paul Yang <yang.yang at baishancloud.com>
(Merged from https://github.com/openssl/openssl/pull/6892)
-----------------------------------------------------------------------
Summary of changes:
crypto/pem/pem_lib.c | 3 +--
test/pemtest.c | 30 ++++++++++++++++++++++--------
2 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/crypto/pem/pem_lib.c b/crypto/pem/pem_lib.c
index 5c21a86..4bb8646 100644
--- a/crypto/pem/pem_lib.c
+++ b/crypto/pem/pem_lib.c
@@ -880,8 +880,7 @@ err:
* Read in PEM-formatted data from the given BIO.
*
* By nature of the PEM format, all content must be printable ASCII (except
- * for line endings). Other characters, or lines that are longer than 80
- * characters, are malformed input and will be rejected.
+ * for line endings). Other characters are malformed input and will be rejected.
*/
int PEM_read_bio_ex(BIO *bp, char **name_out, char **header,
unsigned char **data, long *len_out, unsigned int flags)
diff --git a/test/pemtest.c b/test/pemtest.c
index dfef80d..7f40ea3 100644
--- a/test/pemtest.c
+++ b/test/pemtest.c
@@ -12,18 +12,31 @@
#include <openssl/pem.h>
#include "testutil.h"
+#include "internal/nelem.h"
-static const char raw[] = "hello world";
-static const char encoded[] = "aGVsbG8gd29ybGQ=";
-static const char pemtype[] = "PEMTESTDATA";
+typedef struct {
+ const char *raw;
+ const char *encoded;
+} TESTDATA;
-static int test_b64(void)
+static TESTDATA b64_pem_data[] = {
+ { "hello world",
+ "aGVsbG8gd29ybGQ=" },
+ { "a very ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong input",
+ "YSB2ZXJ5IG9vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29uZyBpbnB1dA==" }
+};
+
+static const char *pemtype = "PEMTESTDATA";
+
+static int test_b64(int idx)
{
BIO *b = BIO_new(BIO_s_mem());
char *name = NULL, *header = NULL;
unsigned char *data = NULL;
long len;
int ret = 0;
+ const char *raw = b64_pem_data[idx].raw;
+ const char *encoded = b64_pem_data[idx].encoded;
if (!TEST_ptr(b)
|| !TEST_true(BIO_printf(b, "-----BEGIN %s-----\n", pemtype))
@@ -32,9 +45,9 @@ static int test_b64(void)
|| !TEST_true(PEM_read_bio_ex(b, &name, &header, &data, &len,
PEM_FLAG_ONLY_B64)))
goto err;
- if (!TEST_int_eq(memcmp(pemtype, name, sizeof(pemtype) - 1), 0)
- || !TEST_int_eq(len,sizeof(raw) - 1)
- || !TEST_int_eq(memcmp(data, raw, sizeof(raw) - 1), 0))
+ if (!TEST_int_eq(memcmp(pemtype, name, strlen(pemtype)), 0)
+ || !TEST_int_eq(len, strlen(raw))
+ || !TEST_int_eq(memcmp(data, raw, strlen(raw)), 0))
goto err;
ret = 1;
err:
@@ -51,6 +64,7 @@ static int test_invalid(void)
char *name = NULL, *header = NULL;
unsigned char *data = NULL;
long len;
+ const char *encoded = b64_pem_data[0].encoded;
if (!TEST_ptr(b)
|| !TEST_true(BIO_printf(b, "-----BEGIN %s-----\n", pemtype))
@@ -71,7 +85,7 @@ static int test_invalid(void)
int setup_tests(void)
{
- ADD_TEST(test_b64);
+ ADD_ALL_TESTS(test_b64, OSSL_NELEM(b64_pem_data));
ADD_TEST(test_invalid);
return 1;
}
More information about the openssl-commits
mailing list