mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
Check wolfSSL_BIO_read
return
This commit is contained in:
@ -43750,7 +43750,10 @@ err:
|
|||||||
if (headerEnd) {
|
if (headerEnd) {
|
||||||
headerEnd += XSTR_SIZEOF("-----");
|
headerEnd += XSTR_SIZEOF("-----");
|
||||||
/* Read in the newline */
|
/* Read in the newline */
|
||||||
(void)wolfSSL_BIO_read(bio, &pem[i], 1);
|
if (wolfSSL_BIO_read(bio, &pem[i], 1) != 1) {
|
||||||
|
WOLFSSL_MSG("wolfSSL_BIO_read error");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
if (*headerEnd != '\n' && *headerEnd != '\r') {
|
if (*headerEnd != '\n' && *headerEnd != '\r') {
|
||||||
WOLFSSL_MSG("Missing newline after header");
|
WOLFSSL_MSG("Missing newline after header");
|
||||||
|
24
tests/api.c
24
tests/api.c
@ -29683,10 +29683,23 @@ static void test_wolfSSL_X509_INFO(void)
|
|||||||
X509_INFO *info;
|
X509_INFO *info;
|
||||||
BIO *cert;
|
BIO *cert;
|
||||||
int i;
|
int i;
|
||||||
|
/* PEM in hex format to avoid null terminator */
|
||||||
byte data[] = {
|
byte data[] = {
|
||||||
"---------BEGIN CERTc-----\n"
|
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47,
|
||||||
"MIIDMTBuQ=\n"
|
0x49, 0x4e, 0x20, 0x43, 0x45, 0x52, 0x54, 0x63, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||||
"-----END -----"
|
0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x44, 0x4d, 0x54, 0x42, 0x75, 0x51, 0x3d,
|
||||||
|
0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x2d, 0x2d,
|
||||||
|
0x2d, 0x2d, 0x2d
|
||||||
|
};
|
||||||
|
/* PEM in hex format to avoid null terminator */
|
||||||
|
byte data2[] = {
|
||||||
|
0x41, 0x53, 0x4e, 0x31, 0x20, 0x4f, 0x49, 0x44, 0x3a, 0x20, 0x70, 0x72,
|
||||||
|
0x69, 0x6d, 0x65, 0x32, 0x35, 0x36, 0x76, 0x31, 0x0a, 0x2d, 0x2d, 0x2d,
|
||||||
|
0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x45, 0x43, 0x20, 0x50,
|
||||||
|
0x41, 0x52, 0x41, 0x4d, 0x45, 0x54, 0x45, 0x52, 0x53, 0x2d, 0x2d, 0x2d,
|
||||||
|
0x2d, 0x43, 0x65, 0x72, 0x74, 0x69, 0x2d, 0x0a, 0x42, 0x67, 0x67, 0x71,
|
||||||
|
0x68, 0x6b, 0x6a, 0x4f, 0x50, 0x51, 0x4d, 0x42, 0x42, 0x77, 0x3d, 0x3d,
|
||||||
|
0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d
|
||||||
};
|
};
|
||||||
|
|
||||||
printf(testingFmt, "wolfSSL_X509_INFO");
|
printf(testingFmt, "wolfSSL_X509_INFO");
|
||||||
@ -29712,6 +29725,11 @@ static void test_wolfSSL_X509_INFO(void)
|
|||||||
AssertNull(info_stack = PEM_X509_INFO_read_bio(cert, NULL, NULL, NULL));
|
AssertNull(info_stack = PEM_X509_INFO_read_bio(cert, NULL, NULL, NULL));
|
||||||
sk_X509_INFO_pop_free(info_stack, X509_INFO_free);
|
sk_X509_INFO_pop_free(info_stack, X509_INFO_free);
|
||||||
BIO_free(cert);
|
BIO_free(cert);
|
||||||
|
AssertNotNull(cert = BIO_new(BIO_s_mem()));
|
||||||
|
AssertIntEQ(BIO_write(cert, data2, sizeof(data2)), sizeof(data2));
|
||||||
|
AssertNull(info_stack = PEM_X509_INFO_read_bio(cert, NULL, NULL, NULL));
|
||||||
|
sk_X509_INFO_pop_free(info_stack, X509_INFO_free);
|
||||||
|
BIO_free(cert);
|
||||||
|
|
||||||
printf(resultFmt, passed);
|
printf(resultFmt, passed);
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user