mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-09 01:00:49 +02:00
845a3a93b5
wolfSSL_BIO_write rejected negative lengths but allowed a large positive length through to wolfSSL_BIO_MEMORY_write. On a fresh buffer an INT_MAX length overflowed the 4/3 buffer growth calculation, so the grow reported success with a short allocation and the following copy read far past the small source buffer. Add an upper bound check that rejects lengths large enough to overflow the growth math before any allocation or copy, and add a regression test that drives a huge length through the public BIO_write entry point.
84 lines
3.6 KiB
C
84 lines
3.6 KiB
C
/* test_ossl_bio.h
|
|
*
|
|
* Copyright (C) 2006-2026 wolfSSL Inc.
|
|
*
|
|
* This file is part of wolfSSL.
|
|
*
|
|
* wolfSSL is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* wolfSSL is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
|
*/
|
|
|
|
#ifndef WOLFCRYPT_TEST_OSSL_BIO_H
|
|
#define WOLFCRYPT_TEST_OSSL_BIO_H
|
|
|
|
#include <tests/api/api_decl.h>
|
|
|
|
#ifndef NO_BIO
|
|
int test_wolfSSL_BIO_gets(void);
|
|
int test_wolfSSL_BIO_puts(void);
|
|
int test_wolfSSL_BIO_dump(void);
|
|
int test_wolfSSL_BIO_should_retry(void);
|
|
int test_wolfSSL_BIO_connect(void);
|
|
int test_wolfSSL_BIO_tls(void);
|
|
int test_wolfSSL_BIO_datagram(void);
|
|
int test_wolfSSL_BIO_s_null(void);
|
|
int test_wolfSSL_BIO_accept(void);
|
|
int test_wolfSSL_BIO_write(void);
|
|
int test_wolfSSL_BIO_read_negative_len(void);
|
|
int test_wolfSSL_BIO_write_large_len(void);
|
|
int test_wolfSSL_BIO_printf(void);
|
|
int test_wolfSSL_BIO_f_md(void);
|
|
int test_wolfSSL_BIO_up_ref(void);
|
|
int test_wolfSSL_BIO_reset(void);
|
|
int test_wolfSSL_BIO_get_len(void);
|
|
int test_wolfSSL_BIO(void);
|
|
int test_wolfSSL_BIO_BIO_ring_read(void);
|
|
int test_wolfSSL_BIO_custom_method(void);
|
|
int test_wolfSSL_BIO_set_conn_hostname(void);
|
|
int test_wolfSSL_BIO_ctrl_pending_chain(void);
|
|
int test_wolfSSL_BIO_meth_type_large(void);
|
|
int test_wolfSSL_BIO_get_init(void);
|
|
|
|
#define TEST_OSSL_BIO_DECLS \
|
|
TEST_DECL_GROUP("ossl_bio", test_wolfSSL_BIO_gets), \
|
|
TEST_DECL_GROUP("ossl_bio", test_wolfSSL_BIO_puts), \
|
|
TEST_DECL_GROUP("ossl_bio", test_wolfSSL_BIO_dump), \
|
|
TEST_DECL_GROUP("ossl_bio", test_wolfSSL_BIO_should_retry), \
|
|
TEST_DECL_GROUP("ossl_bio", test_wolfSSL_BIO_s_null), \
|
|
TEST_DECL_GROUP("ossl_bio", test_wolfSSL_BIO_write), \
|
|
TEST_DECL_GROUP("ossl_bio", test_wolfSSL_BIO_read_negative_len), \
|
|
TEST_DECL_GROUP("ossl_bio", test_wolfSSL_BIO_write_large_len), \
|
|
TEST_DECL_GROUP("ossl_bio", test_wolfSSL_BIO_printf), \
|
|
TEST_DECL_GROUP("ossl_bio", test_wolfSSL_BIO_f_md), \
|
|
TEST_DECL_GROUP("ossl_bio", test_wolfSSL_BIO_up_ref), \
|
|
TEST_DECL_GROUP("ossl_bio", test_wolfSSL_BIO_reset), \
|
|
TEST_DECL_GROUP("ossl_bio", test_wolfSSL_BIO_get_len), \
|
|
TEST_DECL_GROUP("ossl_bio", test_wolfSSL_BIO), \
|
|
TEST_DECL_GROUP("ossl_bio", test_wolfSSL_BIO_BIO_ring_read), \
|
|
TEST_DECL_GROUP("ossl_bio", test_wolfSSL_BIO_custom_method), \
|
|
TEST_DECL_GROUP("ossl_bio", test_wolfSSL_BIO_set_conn_hostname), \
|
|
TEST_DECL_GROUP("ossl_bio", test_wolfSSL_BIO_ctrl_pending_chain), \
|
|
TEST_DECL_GROUP("ossl_bio", test_wolfSSL_BIO_meth_type_large), \
|
|
TEST_DECL_GROUP("ossl_bio", test_wolfSSL_BIO_get_init)
|
|
|
|
#define TEST_OSSL_BIO_TLS_DECLS \
|
|
TEST_DECL_GROUP("ossl_bio_tls", test_wolfSSL_BIO_connect), \
|
|
TEST_DECL_GROUP("ossl_bio_tls", test_wolfSSL_BIO_accept), \
|
|
TEST_DECL_GROUP("ossl_bio_tls", test_wolfSSL_BIO_tls), \
|
|
TEST_DECL_GROUP("ossl_bio_tls", test_wolfSSL_BIO_datagram)
|
|
|
|
#endif
|
|
|
|
#endif /* WOLFCRYPT_TEST_OSSL_BIO_H */
|