Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 644865
"mallocCountTotal" : 637000
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 644868
"mallocCountTotal" : 637000
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 643873
"mallocCountTotal" : 636000
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 643873
"mallocCountTotal" : 636000
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 643873
"mallocCountTotal" : 636000
}
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import class Foundation.ProcessInfo
// Sources/CNIOBoringSSL directory. The source repository is at
// https://boringssl.googlesource.com/boringssl.
//
// BoringSSL Commit: d0a175601b9e180ce58cb1e33649057f5c484146
// BoringSSL Commit: 059585c8dadc7c8170c788f8c89843ee1c5b8f11

/// This function generates the dependencies we want to express.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
const unsigned char *p;
unsigned char *s;
int padding;
uint8_t padding_mask;

if (len < 1) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_STRING_TOO_SHORT);
Expand Down Expand Up @@ -170,7 +171,7 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
}

// Unused bits in a BIT STRING must be zero.
uint8_t padding_mask = (1 << padding) - 1;
padding_mask = (1 << padding) - 1;
if (padding != 0 && (len < 1 || (p[len - 1] & padding_mask) != 0)) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_BIT_STRING_PADDING);
goto err;
Expand All @@ -182,7 +183,7 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
ret->flags |= (ASN1_STRING_FLAG_BITS_LEFT | padding); // set

if (len > 0) {
s = OPENSSL_memdup(p, len);
s = reinterpret_cast<uint8_t *>(OPENSSL_memdup(p, len));
if (s == NULL) {
goto err;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x) {
return NULL;
}
const uint8_t *ptr = data;
void *ret = ASN1_item_d2i(x, &ptr, len, it);
void *ret = ASN1_item_d2i(reinterpret_cast<ASN1_VALUE **>(x), &ptr, len, it);
OPENSSL_free(data);
return ret;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void *ASN1_item_dup(const ASN1_ITEM *it, void *x) {
return NULL;
}

i = ASN1_item_i2d(x, &b, it);
i = ASN1_item_i2d(reinterpret_cast<ASN1_VALUE *>(x), &b, it);
if (b == NULL) {
return NULL;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x) {

int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x) {
unsigned char *b = NULL;
int n = ASN1_item_i2d(x, &b, it);
int n = ASN1_item_i2d(reinterpret_cast<ASN1_VALUE *>(x), &b, it);
if (b == NULL) {
return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ static ASN1_STRING *bn_to_asn1_string(const BIGNUM *bn, ASN1_STRING *ai,
} else {
ret = ai;
}
int len;
if (ret == NULL) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
goto err;
Expand All @@ -419,7 +420,7 @@ static ASN1_STRING *bn_to_asn1_string(const BIGNUM *bn, ASN1_STRING *ai,
ret->type = type;
}

int len = BN_num_bytes(bn);
len = BN_num_bytes(bn);
if (!ASN1_STRING_set(ret, NULL, len) ||
!BN_bn2bin_padded(ret->data, len, bn)) {
goto err;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in,
CBB cbb;
CBB_zero(&cbb);
// If both the same type just copy across
uint8_t *data = NULL;
size_t data_len = 0;
if (inform == outform) {
if (!ASN1_STRING_set(dest, in, len)) {
goto err;
Expand All @@ -245,12 +247,12 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in,
goto err;
}
}
uint8_t *data = NULL;
size_t data_len;
if (// OpenSSL historically NUL-terminated this value with a single byte,
// even for |MBSTRING_BMP| and |MBSTRING_UNIV|.
!CBB_add_u8(&cbb, 0) || !CBB_finish(&cbb, &data, &data_len) ||
data_len < 1 || data_len > INT_MAX) {
if (/* OpenSSL historically NUL-terminated this value with a single byte,
* even for |MBSTRING_BMP| and |MBSTRING_UNIV|. */
!CBB_add_u8(&cbb, 0) || //
!CBB_finish(&cbb, &data, &data_len) || //
data_len < 1 || //
data_len > INT_MAX) {
OPENSSL_PUT_ERROR(ASN1, ERR_R_INTERNAL_ERROR);
OPENSSL_free(data);
goto err;
Expand All @@ -272,7 +274,7 @@ int asn1_is_printable(uint32_t value) {
if (value > 0x7f) {
return 0;
}
return OPENSSL_isalnum(value) || //
return OPENSSL_isalnum(value) || //
value == ' ' || value == '\'' || value == '(' || value == ')' ||
value == '+' || value == ',' || value == '-' || value == '.' ||
value == '/' || value == ':' || value == '=' || value == '?';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ int i2a_ASN1_OBJECT(BIO *bp, const ASN1_OBJECT *a) {
int len = i2t_ASN1_OBJECT(buf, sizeof(buf), a);
if (len > (int)sizeof(buf) - 1) {
// The input was truncated. Allocate a buffer that fits.
allocated = OPENSSL_malloc(len + 1);
allocated = reinterpret_cast<char *>(OPENSSL_malloc(len + 1));
if (allocated == NULL) {
return -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ static int table_cmp(const ASN1_STRING_TABLE *a, const ASN1_STRING_TABLE *b) {
}

static int table_cmp_void(const void *a, const void *b) {
return table_cmp(a, b);
return table_cmp(reinterpret_cast<const ASN1_STRING_TABLE *>(a),
reinterpret_cast<const ASN1_STRING_TABLE *>(b));
}

static uint32_t table_hash(const ASN1_STRING_TABLE *tbl) {
Expand All @@ -169,9 +170,9 @@ static uint32_t table_hash(const ASN1_STRING_TABLE *tbl) {
static const ASN1_STRING_TABLE *asn1_string_table_get(int nid) {
ASN1_STRING_TABLE key;
key.nid = nid;
const ASN1_STRING_TABLE *tbl =
const ASN1_STRING_TABLE *tbl = reinterpret_cast<ASN1_STRING_TABLE *>(
bsearch(&key, tbl_standard, OPENSSL_ARRAY_SIZE(tbl_standard),
sizeof(ASN1_STRING_TABLE), table_cmp_void);
sizeof(ASN1_STRING_TABLE), table_cmp_void));
if (tbl != NULL) {
return tbl;
}
Expand All @@ -198,6 +199,7 @@ int ASN1_STRING_TABLE_add(int nid, long minsize, long maxsize,
int ret = 0;
CRYPTO_MUTEX_lock_write(&string_tables_lock);

ASN1_STRING_TABLE *tbl = NULL;
if (string_tables == NULL) {
string_tables = lh_ASN1_STRING_TABLE_new(table_hash, table_cmp);
if (string_tables == NULL) {
Expand All @@ -214,7 +216,8 @@ int ASN1_STRING_TABLE_add(int nid, long minsize, long maxsize,
}
}

ASN1_STRING_TABLE *tbl = OPENSSL_malloc(sizeof(ASN1_STRING_TABLE));
tbl = reinterpret_cast<ASN1_STRING_TABLE *>(
OPENSSL_malloc(sizeof(ASN1_STRING_TABLE)));
if (tbl == NULL) {
goto err;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value) {
a->value.boolean = value ? ASN1_BOOLEAN_TRUE : ASN1_BOOLEAN_FALSE;
break;
case V_ASN1_OBJECT:
a->value.object = value;
a->value.object = reinterpret_cast<ASN1_OBJECT *>(value);
break;
default:
a->value.asn1_string = value;
a->value.asn1_string = reinterpret_cast<ASN1_STRING *>(value);
break;
}
}
Expand All @@ -151,14 +151,14 @@ int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value) {
ASN1_TYPE_set(a, type, p);
} else if (type == V_ASN1_OBJECT) {
ASN1_OBJECT *odup;
odup = OBJ_dup(value);
odup = OBJ_dup(reinterpret_cast<const ASN1_OBJECT *>(value));
if (!odup) {
return 0;
}
ASN1_TYPE_set(a, type, odup);
} else {
ASN1_STRING *sdup;
sdup = ASN1_STRING_dup(value);
sdup = ASN1_STRING_dup(reinterpret_cast<const ASN1_STRING *>(value));
if (!sdup) {
return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ ASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *str) {
}

int ASN1_STRING_set(ASN1_STRING *str, const void *_data, ossl_ssize_t len_s) {
const char *data = _data;
const char *data = reinterpret_cast<const char *>(_data);
size_t len;
if (len_s < 0) {
if (data == NULL) {
Expand All @@ -291,9 +291,9 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, ossl_ssize_t len_s) {
if (str->length <= (int)len || str->data == NULL) {
unsigned char *c = str->data;
if (c == NULL) {
str->data = OPENSSL_malloc(len + 1);
str->data = reinterpret_cast<uint8_t *>(OPENSSL_malloc(len + 1));
} else {
str->data = OPENSSL_realloc(c, len + 1);
str->data = reinterpret_cast<uint8_t *>(OPENSSL_realloc(c, len + 1));
}

if (str->data == NULL) {
Expand All @@ -315,7 +315,7 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, ossl_ssize_t len_s) {

void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len) {
OPENSSL_free(str->data);
str->data = data;
str->data = reinterpret_cast<uint8_t *>(data);
str->length = len;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **out) {
uint8_t *new_data = NULL;
int len = ASN1_item_i2d(obj, &new_data, it);
int len = ASN1_item_i2d(reinterpret_cast<ASN1_VALUE *>(obj), &new_data, it);
if (len <= 0) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ENCODE_ERROR);
return NULL;
Expand Down Expand Up @@ -91,7 +91,7 @@ void *ASN1_item_unpack(const ASN1_STRING *oct, const ASN1_ITEM *it) {
void *ret = ASN1_item_d2i(NULL, &p, oct->length, it);
if (ret == NULL || p != oct->data + oct->length) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_DECODE_ERROR);
ASN1_item_free(ret, it);
ASN1_item_free(reinterpret_cast<ASN1_VALUE *>(ret), it);
return NULL;
}
return ret;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ int OPENSSL_tm_to_posix(const struct tm *tm, int64_t *out) {
}

int OPENSSL_posix_to_tm(int64_t time, struct tm *out_tm) {
struct tm tmp_tm = {0};
struct tm tmp_tm = {};
if (!utc_from_posix_time(time, &tmp_tm.tm_year, &tmp_tm.tm_mon,
&tmp_tm.tm_mday, &tmp_tm.tm_hour, &tmp_tm.tm_min,
&tmp_tm.tm_sec)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ static int asn1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in,
OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
goto err;
}
const ASN1_EXTERN_FUNCS *ef = it->funcs;
const ASN1_EXTERN_FUNCS *ef =
reinterpret_cast<const ASN1_EXTERN_FUNCS *>(it->funcs);
return ef->asn1_ex_d2i(pval, in, len, it, opt, NULL);
}

Expand All @@ -294,7 +295,7 @@ static int asn1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in,
goto err;
}

const ASN1_AUX *aux = it->funcs;
const ASN1_AUX *aux = reinterpret_cast<const ASN1_AUX *>(it->funcs);
ASN1_aux_cb *asn1_cb = aux != NULL ? aux->asn1_cb : NULL;
if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL)) {
goto auxerr;
Expand Down Expand Up @@ -379,7 +380,7 @@ static int asn1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in,
goto err;
}

const ASN1_AUX *aux = it->funcs;
const ASN1_AUX *aux = reinterpret_cast<const ASN1_AUX *>(it->funcs);
ASN1_aux_cb *asn1_cb = aux != NULL ? aux->asn1_cb : NULL;
if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL)) {
goto auxerr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it) {
if (len <= 0) {
return len;
}
buf = OPENSSL_malloc(len);
buf = reinterpret_cast<uint8_t *>(OPENSSL_malloc(len));
if (!buf) {
return -1;
}
Expand Down Expand Up @@ -191,7 +191,8 @@ int asn1_item_ex_i2d_opt(ASN1_VALUE **pval, unsigned char **out,
OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
return -1;
}
const ASN1_EXTERN_FUNCS *ef = it->funcs;
const ASN1_EXTERN_FUNCS *ef =
reinterpret_cast<const ASN1_EXTERN_FUNCS *>(it->funcs);
int ret = ef->asn1_ex_i2d(pval, out, it);
if (ret == 0) {
// |asn1_ex_i2d| should never return zero. We have already checked
Expand Down Expand Up @@ -424,7 +425,8 @@ typedef struct {
} DER_ENC;

static int der_cmp(const void *a, const void *b) {
const DER_ENC *d1 = a, *d2 = b;
const DER_ENC *d1 = reinterpret_cast<const DER_ENC *>(a),
*d2 = reinterpret_cast<const DER_ENC *>(b);
int cmplen, i;
cmplen = (d1->length < d2->length) ? d1->length : d2->length;
i = OPENSSL_memcmp(d1->data, d2->data, cmplen);
Expand Down Expand Up @@ -453,14 +455,15 @@ static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out,
}

int ret = 0;
unsigned char *const buf = OPENSSL_malloc(skcontlen);
DER_ENC *encoded = OPENSSL_calloc(sk_ASN1_VALUE_num(sk), sizeof(*encoded));
uint8_t *const buf = reinterpret_cast<uint8_t *>(OPENSSL_malloc(skcontlen));
DER_ENC *encoded = reinterpret_cast<DER_ENC *>(
OPENSSL_calloc(sk_ASN1_VALUE_num(sk), sizeof(*encoded)));
uint8_t *p = buf;
if (encoded == NULL || buf == NULL) {
goto err;
}

// Encode all the elements into |buf| and populate |encoded|.
unsigned char *p = buf;
for (size_t i = 0; i < sk_ASN1_VALUE_num(sk); i++) {
ASN1_VALUE *skitem = sk_ASN1_VALUE_value(sk, i);
encoded[i].data = p;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) {
break;

case ASN1_ITYPE_CHOICE: {
const ASN1_AUX *aux = it->funcs;
const ASN1_AUX *aux = reinterpret_cast<const ASN1_AUX *>(it->funcs);
ASN1_aux_cb *asn1_cb = aux != NULL ? aux->asn1_cb : NULL;
if (asn1_cb) {
i = asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL);
Expand All @@ -118,7 +118,7 @@ void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) {
}

case ASN1_ITYPE_EXTERN:
ef = it->funcs;
ef = reinterpret_cast<const ASN1_EXTERN_FUNCS *>(it->funcs);
if (ef && ef->asn1_ex_free) {
ef->asn1_ex_free(pval, it);
}
Expand All @@ -128,7 +128,7 @@ void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) {
if (!asn1_refcount_dec_and_test_zero(pval, it)) {
return;
}
const ASN1_AUX *aux = it->funcs;
const ASN1_AUX *aux = reinterpret_cast<const ASN1_AUX *>(it->funcs);
ASN1_aux_cb *asn1_cb = aux != NULL ? aux->asn1_cb : NULL;
if (asn1_cb) {
i = asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL);
Expand Down
Loading