From a04d78d392463df4e69a64360c952ffa5abd22f7 Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Fri, 25 Sep 2015 00:26:37 +0000 Subject: Revert "external/boringssl: sync with upstream." This reverts commit 1e4884f615b20946411a74e41eb9c6aa65e2d5f3. This breaks some x86 builds. Change-Id: I4d4310663ce52bc0a130e6b9dbc22b868ff4fb25 --- src/crypto/conf/conf.c | 64 +++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 34 deletions(-) (limited to 'src/crypto/conf/conf.c') diff --git a/src/crypto/conf/conf.c b/src/crypto/conf/conf.c index e098a2c..213efc5 100644 --- a/src/crypto/conf/conf.c +++ b/src/crypto/conf/conf.c @@ -111,16 +111,6 @@ CONF *NCONF_new(void *method) { return conf; } -CONF_VALUE *CONF_VALUE_new(void) { - CONF_VALUE *v = OPENSSL_malloc(sizeof(CONF_VALUE)); - if (!v) { - OPENSSL_PUT_ERROR(CONF, ERR_R_MALLOC_FAILURE); - return NULL; - } - memset(v, 0, sizeof(CONF_VALUE)); - return v; -} - static void value_free_contents(CONF_VALUE *value) { if (value->section) { OPENSSL_free(value->section); @@ -147,26 +137,29 @@ void NCONF_free(CONF *conf) { return; } - lh_CONF_VALUE_doall(conf->data, value_free); + lh_CONF_VALUE_doall(conf->data, value_free_contents); lh_CONF_VALUE_free(conf->data); OPENSSL_free(conf); } CONF_VALUE *NCONF_new_section(const CONF *conf, const char *section) { STACK_OF(CONF_VALUE) *sk = NULL; - int ok = 0; + int ok = 0, i; CONF_VALUE *v = NULL, *old_value; sk = sk_CONF_VALUE_new_null(); - v = CONF_VALUE_new(); + v = OPENSSL_malloc(sizeof(CONF_VALUE)); if (sk == NULL || v == NULL) { goto err; } - v->section = OPENSSL_strdup(section); + i = strlen(section) + 1; + v->section = OPENSSL_malloc(i); if (v->section == NULL) { goto err; } + memcpy(v->section, section, i); + v->section[i-1] = 0; v->name = NULL; v->value = (char *)sk; @@ -292,7 +285,7 @@ static int str_copy(CONF *conf, char *section, char **pto, char *from) { rp = e; if (q) { if (r != q) { - OPENSSL_PUT_ERROR(CONF, CONF_R_NO_CLOSE_BRACE); + OPENSSL_PUT_ERROR(CONF, str_copy, CONF_R_NO_CLOSE_BRACE); goto err; } e++; @@ -311,7 +304,7 @@ static int str_copy(CONF *conf, char *section, char **pto, char *from) { } *rp = r; if (p == NULL) { - OPENSSL_PUT_ERROR(CONF, CONF_R_VARIABLE_HAS_NO_VALUE); + OPENSSL_PUT_ERROR(CONF, str_copy, CONF_R_VARIABLE_HAS_NO_VALUE); goto err; } BUF_MEM_grow_clean(buf, (strlen(p) + buf->length - (e - from))); @@ -379,12 +372,11 @@ const char *NCONF_get_string(const CONF *conf, const char *section, return value->value; } -static int add_string(const CONF *conf, CONF_VALUE *section, - CONF_VALUE *value) { +int add_string(const CONF *conf, CONF_VALUE *section, CONF_VALUE *value) { STACK_OF(CONF_VALUE) *section_stack = (STACK_OF(CONF_VALUE)*) section->value; CONF_VALUE *old_value; - value->section = OPENSSL_strdup(section->section); + value->section = section->section; if (!sk_CONF_VALUE_push(section_stack, value)) { return 0; } @@ -513,19 +505,20 @@ static int def_load_bio(CONF *conf, BIO *in, long *out_error_line) { char *start, *psection, *pname; if ((buff = BUF_MEM_new()) == NULL) { - OPENSSL_PUT_ERROR(CONF, ERR_R_BUF_LIB); + OPENSSL_PUT_ERROR(CONF, def_load_bio, ERR_R_BUF_LIB); goto err; } - section = OPENSSL_strdup("default"); + section = (char *)OPENSSL_malloc(10); if (section == NULL) { - OPENSSL_PUT_ERROR(CONF, ERR_R_MALLOC_FAILURE); + OPENSSL_PUT_ERROR(CONF, def_load_bio, ERR_R_MALLOC_FAILURE); goto err; } + BUF_strlcpy(section, "default", 10); sv = NCONF_new_section(conf, section); if (sv == NULL) { - OPENSSL_PUT_ERROR(CONF, CONF_R_UNABLE_TO_CREATE_NEW_SECTION); + OPENSSL_PUT_ERROR(CONF, def_load_bio, CONF_R_UNABLE_TO_CREATE_NEW_SECTION); goto err; } @@ -533,7 +526,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *out_error_line) { again = 0; for (;;) { if (!BUF_MEM_grow(buff, bufnum + CONFBUFSIZE)) { - OPENSSL_PUT_ERROR(CONF, ERR_R_BUF_LIB); + OPENSSL_PUT_ERROR(CONF, def_load_bio, ERR_R_BUF_LIB); goto err; } p = &(buff->data[bufnum]); @@ -602,7 +595,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *out_error_line) { ss = p; goto again; } - OPENSSL_PUT_ERROR(CONF, CONF_R_MISSING_CLOSE_SQUARE_BRACKET); + OPENSSL_PUT_ERROR(CONF, def_load_bio, CONF_R_MISSING_CLOSE_SQUARE_BRACKET); goto err; } *end = '\0'; @@ -613,7 +606,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *out_error_line) { sv = NCONF_new_section(conf, section); } if (sv == NULL) { - OPENSSL_PUT_ERROR(CONF, CONF_R_UNABLE_TO_CREATE_NEW_SECTION); + OPENSSL_PUT_ERROR(CONF, def_load_bio, CONF_R_UNABLE_TO_CREATE_NEW_SECTION); goto err; } continue; @@ -630,7 +623,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *out_error_line) { } p = eat_ws(conf, end); if (*p != '=') { - OPENSSL_PUT_ERROR(CONF, CONF_R_MISSING_EQUAL_SIGN); + OPENSSL_PUT_ERROR(CONF, def_load_bio, CONF_R_MISSING_EQUAL_SIGN); goto err; } *end = '\0'; @@ -646,17 +639,20 @@ static int def_load_bio(CONF *conf, BIO *in, long *out_error_line) { p++; *p = '\0'; - if (!(v = CONF_VALUE_new())) { + if (!(v = (CONF_VALUE *)OPENSSL_malloc(sizeof(CONF_VALUE)))) { + OPENSSL_PUT_ERROR(CONF, def_load_bio, ERR_R_MALLOC_FAILURE); goto err; } if (psection == NULL) { psection = section; } - v->name = OPENSSL_strdup(pname); + v->name = (char *)OPENSSL_malloc(strlen(pname) + 1); + v->value = NULL; if (v->name == NULL) { - OPENSSL_PUT_ERROR(CONF, ERR_R_MALLOC_FAILURE); + OPENSSL_PUT_ERROR(CONF, def_load_bio, ERR_R_MALLOC_FAILURE); goto err; } + BUF_strlcpy(v->name, pname, strlen(pname) + 1); if (!str_copy(conf, psection, &(v->value), start)) { goto err; } @@ -666,14 +662,14 @@ static int def_load_bio(CONF *conf, BIO *in, long *out_error_line) { tv = NCONF_new_section(conf, psection); } if (tv == NULL) { - OPENSSL_PUT_ERROR(CONF, CONF_R_UNABLE_TO_CREATE_NEW_SECTION); + OPENSSL_PUT_ERROR(CONF, def_load_bio, CONF_R_UNABLE_TO_CREATE_NEW_SECTION); goto err; } } else { tv = sv; } if (add_string(conf, tv, v) == 0) { - OPENSSL_PUT_ERROR(CONF, ERR_R_MALLOC_FAILURE); + OPENSSL_PUT_ERROR(CONF, def_load_bio, ERR_R_MALLOC_FAILURE); goto err; } v = NULL; @@ -719,7 +715,7 @@ int NCONF_load(CONF *conf, const char *filename, long *out_error_line) { int ret; if (in == NULL) { - OPENSSL_PUT_ERROR(CONF, ERR_R_SYS_LIB); + OPENSSL_PUT_ERROR(CONF, NCONF_load, ERR_R_SYS_LIB); return 0; } @@ -740,7 +736,7 @@ int CONF_parse_list(const char *list, char sep, int remove_whitespace, const char *lstart, *tmpend, *p; if (list == NULL) { - OPENSSL_PUT_ERROR(CONF, CONF_R_LIST_CANNOT_BE_NULL); + OPENSSL_PUT_ERROR(CONF, CONF_parse_list, CONF_R_LIST_CANNOT_BE_NULL); return 0; } -- cgit v1.1