Use |OPENSSL_strdup| instead of insane alternatives.
Change-Id: I1e6fd4abb7709d53f3663b1626f0bc147b9cd453 Reviewed-on: https://boringssl-review.googlesource.com/5741 Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
parent
28bc6eba28
commit
e9c283025e
@ -144,7 +144,7 @@ void NCONF_free(CONF *conf) {
|
|||||||
|
|
||||||
CONF_VALUE *NCONF_new_section(const CONF *conf, const char *section) {
|
CONF_VALUE *NCONF_new_section(const CONF *conf, const char *section) {
|
||||||
STACK_OF(CONF_VALUE) *sk = NULL;
|
STACK_OF(CONF_VALUE) *sk = NULL;
|
||||||
int ok = 0, i;
|
int ok = 0;
|
||||||
CONF_VALUE *v = NULL, *old_value;
|
CONF_VALUE *v = NULL, *old_value;
|
||||||
|
|
||||||
sk = sk_CONF_VALUE_new_null();
|
sk = sk_CONF_VALUE_new_null();
|
||||||
@ -152,14 +152,11 @@ CONF_VALUE *NCONF_new_section(const CONF *conf, const char *section) {
|
|||||||
if (sk == NULL || v == NULL) {
|
if (sk == NULL || v == NULL) {
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
i = strlen(section) + 1;
|
v->section = OPENSSL_strdup(section);
|
||||||
v->section = OPENSSL_malloc(i);
|
|
||||||
if (v->section == NULL) {
|
if (v->section == NULL) {
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(v->section, section, i);
|
|
||||||
v->section[i-1] = 0;
|
|
||||||
v->name = NULL;
|
v->name = NULL;
|
||||||
v->value = (char *)sk;
|
v->value = (char *)sk;
|
||||||
|
|
||||||
@ -509,12 +506,11 @@ static int def_load_bio(CONF *conf, BIO *in, long *out_error_line) {
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
section = (char *)OPENSSL_malloc(10);
|
section = OPENSSL_strdup("default");
|
||||||
if (section == NULL) {
|
if (section == NULL) {
|
||||||
OPENSSL_PUT_ERROR(CONF, ERR_R_MALLOC_FAILURE);
|
OPENSSL_PUT_ERROR(CONF, ERR_R_MALLOC_FAILURE);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
BUF_strlcpy(section, "default", 10);
|
|
||||||
|
|
||||||
sv = NCONF_new_section(conf, section);
|
sv = NCONF_new_section(conf, section);
|
||||||
if (sv == NULL) {
|
if (sv == NULL) {
|
||||||
@ -646,13 +642,12 @@ static int def_load_bio(CONF *conf, BIO *in, long *out_error_line) {
|
|||||||
if (psection == NULL) {
|
if (psection == NULL) {
|
||||||
psection = section;
|
psection = section;
|
||||||
}
|
}
|
||||||
v->name = (char *)OPENSSL_malloc(strlen(pname) + 1);
|
|
||||||
v->value = NULL;
|
v->value = NULL;
|
||||||
|
v->name = OPENSSL_strdup(pname);
|
||||||
if (v->name == NULL) {
|
if (v->name == NULL) {
|
||||||
OPENSSL_PUT_ERROR(CONF, ERR_R_MALLOC_FAILURE);
|
OPENSSL_PUT_ERROR(CONF, ERR_R_MALLOC_FAILURE);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
BUF_strlcpy(v->name, pname, strlen(pname) + 1);
|
|
||||||
if (!str_copy(conf, psection, &(v->value), start)) {
|
if (!str_copy(conf, psection, &(v->value), start)) {
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user