mirror of
https://github.com/openssl/openssl.git
synced 2025-02-17 14:32:04 +08:00
CORE: Add upcalls for BIO_gets() and BIO_puts()
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/12410)
This commit is contained in:
parent
072a9fde7d
commit
853ca12813
@ -1061,6 +1061,8 @@ static const OSSL_DISPATCH core_dispatch_[] = {
|
||||
{ OSSL_FUNC_BIO_NEW_MEMBUF, (void (*)(void))BIO_new_mem_buf },
|
||||
{ OSSL_FUNC_BIO_READ_EX, (void (*)(void))BIO_read_ex },
|
||||
{ OSSL_FUNC_BIO_WRITE_EX, (void (*)(void))BIO_write_ex },
|
||||
{ OSSL_FUNC_BIO_GETS, (void (*)(void))BIO_gets },
|
||||
{ OSSL_FUNC_BIO_PUTS, (void (*)(void))BIO_puts },
|
||||
{ OSSL_FUNC_BIO_FREE, (void (*)(void))BIO_free },
|
||||
{ OSSL_FUNC_BIO_VPRINTF, (void (*)(void))BIO_vprintf },
|
||||
{ OSSL_FUNC_BIO_VSNPRINTF, (void (*)(void))BIO_vsnprintf },
|
||||
|
@ -135,6 +135,9 @@ OSSL_CORE_MAKE_FUNC(void,
|
||||
#define OSSL_FUNC_BIO_FREE 44
|
||||
#define OSSL_FUNC_BIO_VPRINTF 45
|
||||
#define OSSL_FUNC_BIO_VSNPRINTF 46
|
||||
#define OSSL_FUNC_BIO_PUTS 47
|
||||
#define OSSL_FUNC_BIO_GETS 48
|
||||
|
||||
|
||||
OSSL_CORE_MAKE_FUNC(OSSL_CORE_BIO *, BIO_new_file, (const char *filename,
|
||||
const char *mode))
|
||||
@ -143,6 +146,8 @@ OSSL_CORE_MAKE_FUNC(int, BIO_read_ex, (OSSL_CORE_BIO *bio, void *data,
|
||||
size_t data_len, size_t *bytes_read))
|
||||
OSSL_CORE_MAKE_FUNC(int, BIO_write_ex, (OSSL_CORE_BIO *bio, const void *data,
|
||||
size_t data_len, size_t *written))
|
||||
OSSL_CORE_MAKE_FUNC(int, BIO_gets, (OSSL_CORE_BIO *bio, char *buf, int size))
|
||||
OSSL_CORE_MAKE_FUNC(int, BIO_puts, (OSSL_CORE_BIO *bio, const char *str))
|
||||
OSSL_CORE_MAKE_FUNC(int, BIO_free, (OSSL_CORE_BIO *bio))
|
||||
OSSL_CORE_MAKE_FUNC(int, BIO_vprintf, (OSSL_CORE_BIO *bio, const char *format,
|
||||
va_list args))
|
||||
|
@ -16,6 +16,8 @@ static OSSL_FUNC_BIO_new_file_fn *c_bio_new_file = NULL;
|
||||
static OSSL_FUNC_BIO_new_membuf_fn *c_bio_new_membuf = NULL;
|
||||
static OSSL_FUNC_BIO_read_ex_fn *c_bio_read_ex = NULL;
|
||||
static OSSL_FUNC_BIO_write_ex_fn *c_bio_write_ex = NULL;
|
||||
static OSSL_FUNC_BIO_gets_fn *c_bio_gets = NULL;
|
||||
static OSSL_FUNC_BIO_puts_fn *c_bio_puts = NULL;
|
||||
static OSSL_FUNC_BIO_free_fn *c_bio_free = NULL;
|
||||
static OSSL_FUNC_BIO_vprintf_fn *c_bio_vprintf = NULL;
|
||||
|
||||
@ -39,6 +41,14 @@ int ossl_prov_bio_from_dispatch(const OSSL_DISPATCH *fns)
|
||||
if (c_bio_write_ex == NULL)
|
||||
c_bio_write_ex = OSSL_FUNC_BIO_write_ex(fns);
|
||||
break;
|
||||
case OSSL_FUNC_BIO_GETS:
|
||||
if (c_bio_gets == NULL)
|
||||
c_bio_gets = OSSL_FUNC_BIO_gets(fns);
|
||||
break;
|
||||
case OSSL_FUNC_BIO_PUTS:
|
||||
if (c_bio_puts == NULL)
|
||||
c_bio_puts = OSSL_FUNC_BIO_puts(fns);
|
||||
break;
|
||||
case OSSL_FUNC_BIO_FREE:
|
||||
if (c_bio_free == NULL)
|
||||
c_bio_free = OSSL_FUNC_BIO_free(fns);
|
||||
@ -83,6 +93,20 @@ int ossl_prov_bio_write_ex(OSSL_CORE_BIO *bio, const void *data, size_t data_len
|
||||
return c_bio_write_ex(bio, data, data_len, written);
|
||||
}
|
||||
|
||||
int ossl_prov_bio_gets(OSSL_CORE_BIO *bio, char *buf, int size)
|
||||
{
|
||||
if (c_bio_gets == NULL)
|
||||
return -1;
|
||||
return c_bio_gets(bio, buf, size);
|
||||
}
|
||||
|
||||
int ossl_prov_bio_puts(OSSL_CORE_BIO *bio, const char *str)
|
||||
{
|
||||
if (c_bio_puts == NULL)
|
||||
return -1;
|
||||
return c_bio_puts(bio, str);
|
||||
}
|
||||
|
||||
int ossl_prov_bio_free(OSSL_CORE_BIO *bio)
|
||||
{
|
||||
if (c_bio_free == NULL)
|
||||
@ -134,16 +158,12 @@ static long bio_core_ctrl(BIO *bio, int cmd, long num, void *ptr)
|
||||
|
||||
static int bio_core_gets(BIO *bio, char *buf, int size)
|
||||
{
|
||||
/* We don't support this */
|
||||
assert(0);
|
||||
return -1;
|
||||
return ossl_prov_bio_gets(BIO_get_data(bio), buf, size);
|
||||
}
|
||||
|
||||
static int bio_core_puts(BIO *bio, const char *str)
|
||||
{
|
||||
/* We don't support this */
|
||||
assert(0);
|
||||
return -1;
|
||||
return ossl_prov_bio_puts(BIO_get_data(bio), str);
|
||||
}
|
||||
|
||||
static int bio_core_new(BIO *bio)
|
||||
|
@ -20,6 +20,8 @@ int ossl_prov_bio_read_ex(OSSL_CORE_BIO *bio, void *data, size_t data_len,
|
||||
size_t *bytes_read);
|
||||
int ossl_prov_bio_write_ex(OSSL_CORE_BIO *bio, const void *data, size_t data_len,
|
||||
size_t *written);
|
||||
int ossl_prov_bio_gets(OSSL_CORE_BIO *bio, char *buf, int size);
|
||||
int ossl_prov_bio_puts(OSSL_CORE_BIO *bio, const char *str);
|
||||
int ossl_prov_bio_free(OSSL_CORE_BIO *bio);
|
||||
int ossl_prov_bio_vprintf(OSSL_CORE_BIO *bio, const char *format, va_list ap);
|
||||
int ossl_prov_bio_printf(OSSL_CORE_BIO *bio, const char *format, ...);
|
||||
|
Loading…
Reference in New Issue
Block a user