提交 6dbe4dc4 编写于 作者: R Rich Salz

Copy name string in BIO_meth_new

Reviewed-by: NRichard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5318)
上级 4e075253
/* /*
* Generated by util/mkerr.pl DO NOT EDIT * Generated by util/mkerr.pl DO NOT EDIT
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
* *
* Licensed under the OpenSSL license (the "License"). You may not use * Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy * this file except in compliance with the License. You can obtain a copy
...@@ -30,6 +30,7 @@ static const ERR_STRING_DATA BIO_str_functs[] = { ...@@ -30,6 +30,7 @@ static const ERR_STRING_DATA BIO_str_functs[] = {
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_LOOKUP, 0), "BIO_lookup"}, {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_LOOKUP, 0), "BIO_lookup"},
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_LOOKUP_EX, 0), "BIO_lookup_ex"}, {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_LOOKUP_EX, 0), "BIO_lookup_ex"},
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_MAKE_PAIR, 0), "bio_make_pair"}, {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_MAKE_PAIR, 0), "bio_make_pair"},
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_METH_NEW, 0), "BIO_meth_new"},
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NEW, 0), "BIO_new"}, {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NEW, 0), "BIO_new"},
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NEW_DGRAM_SCTP, 0), "BIO_new_dgram_sctp"}, {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NEW_DGRAM_SCTP, 0), "BIO_new_dgram_sctp"},
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NEW_FILE, 0), "BIO_new_file"}, {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NEW_FILE, 0), "BIO_new_file"},
......
...@@ -37,16 +37,22 @@ BIO_METHOD *BIO_meth_new(int type, const char *name) ...@@ -37,16 +37,22 @@ BIO_METHOD *BIO_meth_new(int type, const char *name)
{ {
BIO_METHOD *biom = OPENSSL_zalloc(sizeof(BIO_METHOD)); BIO_METHOD *biom = OPENSSL_zalloc(sizeof(BIO_METHOD));
if (biom != NULL) { if (biom == NULL
biom->type = type; || (biom->name = OPENSSL_strdup(name)) == NULL) {
biom->name = name; OPENSSL_free(biom);
BIOerr(BIO_F_BIO_METH_NEW, ERR_R_MALLOC_FAILURE);
return NULL;
} }
biom->type = type;
return biom; return biom;
} }
void BIO_meth_free(BIO_METHOD *biom) void BIO_meth_free(BIO_METHOD *biom)
{ {
OPENSSL_free(biom); if (biom != NULL) {
OPENSSL_free(biom->name);
OPENSSL_free(biom);
}
} }
int (*BIO_meth_get_write(BIO_METHOD *biom)) (BIO *, const char *, int) int (*BIO_meth_get_write(BIO_METHOD *biom)) (BIO *, const char *, int)
......
...@@ -127,6 +127,7 @@ BIO_F_BIO_LISTEN:139:BIO_listen ...@@ -127,6 +127,7 @@ BIO_F_BIO_LISTEN:139:BIO_listen
BIO_F_BIO_LOOKUP:135:BIO_lookup BIO_F_BIO_LOOKUP:135:BIO_lookup
BIO_F_BIO_LOOKUP_EX:143:BIO_lookup_ex BIO_F_BIO_LOOKUP_EX:143:BIO_lookup_ex
BIO_F_BIO_MAKE_PAIR:121:bio_make_pair BIO_F_BIO_MAKE_PAIR:121:bio_make_pair
BIO_F_BIO_METH_NEW:146:BIO_meth_new
BIO_F_BIO_NEW:108:BIO_new BIO_F_BIO_NEW:108:BIO_new
BIO_F_BIO_NEW_DGRAM_SCTP:145:BIO_new_dgram_sctp BIO_F_BIO_NEW_DGRAM_SCTP:145:BIO_new_dgram_sctp
BIO_F_BIO_NEW_FILE:109:BIO_new_file BIO_F_BIO_NEW_FILE:109:BIO_new_file
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
struct bio_method_st { struct bio_method_st {
int type; int type;
const char *name; char *name;
int (*bwrite) (BIO *, const char *, size_t, size_t *); int (*bwrite) (BIO *, const char *, size_t, size_t *);
int (*bwrite_old) (BIO *, const char *, int); int (*bwrite_old) (BIO *, const char *, int);
int (*bread) (BIO *, char *, size_t, size_t *); int (*bread) (BIO *, char *, size_t, size_t *);
......
...@@ -35,6 +35,7 @@ int ERR_load_BIO_strings(void); ...@@ -35,6 +35,7 @@ int ERR_load_BIO_strings(void);
# define BIO_F_BIO_LOOKUP 135 # define BIO_F_BIO_LOOKUP 135
# define BIO_F_BIO_LOOKUP_EX 143 # define BIO_F_BIO_LOOKUP_EX 143
# define BIO_F_BIO_MAKE_PAIR 121 # define BIO_F_BIO_MAKE_PAIR 121
# define BIO_F_BIO_METH_NEW 146
# define BIO_F_BIO_NEW 108 # define BIO_F_BIO_NEW 108
# define BIO_F_BIO_NEW_DGRAM_SCTP 145 # define BIO_F_BIO_NEW_DGRAM_SCTP 145
# define BIO_F_BIO_NEW_FILE 109 # define BIO_F_BIO_NEW_FILE 109
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册