Skip to content

Commit f652300

Browse files
authored
Update BoringSSL to 0faffc7a30eeb195248ea43056f4848e2a9b1c6d (#134)
1 parent d11194a commit f652300

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1023
-895
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// Sources/CCryptoBoringSSL directory. The source repository is at
2121
// https://boringssl.googlesource.com/boringssl.
2222
//
23-
// BoringSSL Commit: cab31f65f1ad6e6daca62e95b25dd6cd805fce0b
23+
// BoringSSL Commit: 0faffc7a30eeb195248ea43056f4848e2a9b1c6d
2424

2525
import PackageDescription
2626

Sources/CCryptoBoringSSL/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ add_library(CCryptoBoringSSL STATIC
2929
"crypto/asn1/a_time.c"
3030
"crypto/asn1/a_type.c"
3131
"crypto/asn1/a_utctm.c"
32-
"crypto/asn1/a_utf8.c"
3332
"crypto/asn1/asn1_lib.c"
3433
"crypto/asn1/asn1_par.c"
3534
"crypto/asn1/asn_pack.c"
@@ -76,10 +75,12 @@ add_library(CCryptoBoringSSL STATIC
7675
"crypto/cipher_extra/tls_cbc.c"
7776
"crypto/conf/conf.c"
7877
"crypto/cpu_aarch64_apple.c"
78+
"crypto/cpu_aarch64_freebsd.c"
7979
"crypto/cpu_aarch64_fuchsia.c"
8080
"crypto/cpu_aarch64_linux.c"
8181
"crypto/cpu_aarch64_win.c"
8282
"crypto/cpu_arm.c"
83+
"crypto/cpu_arm_freebsd.c"
8384
"crypto/cpu_arm_linux.c"
8485
"crypto/cpu_intel.c"
8586
"crypto/cpu_ppc64le.c"

Sources/CCryptoBoringSSL/crypto/asn1/a_bitstr.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ int i2c_ASN1_BIT_STRING(const ASN1_BIT_STRING *a, unsigned char **pp) {
115115

116116
uint8_t bits;
117117
int len = asn1_bit_string_length(a, &bits);
118+
if (len > INT_MAX - 1) {
119+
OPENSSL_PUT_ERROR(ASN1, ERR_R_OVERFLOW);
120+
return 0;
121+
}
118122
int ret = 1 + len;
119123
if (pp == NULL) {
120124
return ret;

Sources/CCryptoBoringSSL/crypto/asn1/a_strex.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,17 @@ static int do_buf(const unsigned char *buf, int buflen, int encoding,
167167
}
168168
const int is_last = CBS_len(&cbs) == 0;
169169
if (flags & ASN1_STRFLGS_UTF8_CONVERT) {
170-
unsigned char utfbuf[6];
171-
int utflen;
172-
utflen = UTF8_putc(utfbuf, sizeof(utfbuf), c);
173-
for (int i = 0; i < utflen; i++) {
174-
int len = do_esc_char(utfbuf[i], flags, quotes, out, is_first && i == 0,
175-
is_last && i == utflen - 1);
170+
uint8_t utf8_buf[6];
171+
CBB utf8_cbb;
172+
CBB_init_fixed(&utf8_cbb, utf8_buf, sizeof(utf8_buf));
173+
if (!cbb_add_utf8(&utf8_cbb, c)) {
174+
OPENSSL_PUT_ERROR(ASN1, ERR_R_INTERNAL_ERROR);
175+
return 1;
176+
}
177+
size_t utf8_len = CBB_len(&utf8_cbb);
178+
for (size_t i = 0; i < utf8_len; i++) {
179+
int len = do_esc_char(utf8_buf[i], flags, quotes, out,
180+
is_first && i == 0, is_last && i == utf8_len - 1);
176181
if (len < 0) {
177182
return -1;
178183
}

Sources/CCryptoBoringSSL/crypto/asn1/a_utf8.c

Lines changed: 0 additions & 142 deletions
This file was deleted.

Sources/CCryptoBoringSSL/crypto/asn1/internal.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ OPENSSL_EXPORT int OPENSSL_timegm(const struct tm *tm, time_t *out);
9696
// |offset_day| days and |offset_sec| seconds. It returns zero on failure. |tm|
9797
// must be in the range of year 0000 to 9999 both before and after the update or
9898
// a failure will be returned.
99-
int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec);
99+
OPENSSL_EXPORT int OPENSSL_gmtime_adj(struct tm *tm, int offset_day,
100+
long offset_sec);
100101

101102
// OPENSSL_gmtime_diff calculates the difference between |from| and |to|. It
102103
// returns one, and outputs the difference as a number of days and seconds in
@@ -156,8 +157,6 @@ OPENSSL_EXPORT int asn1_generalizedtime_to_tm(struct tm *tm,
156157
void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it,
157158
int combine);
158159

159-
int UTF8_putc(unsigned char *str, int len, uint32_t value);
160-
161160
int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
162161
void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
163162

Sources/CCryptoBoringSSL/crypto/asn1/posix_time.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,10 @@ int OPENSSL_gmtime_adj(struct tm *tm, int off_day, long offset_sec) {
191191
tm->tm_hour, tm->tm_min, tm->tm_sec, &posix_time)) {
192192
return 0;
193193
}
194-
if (!utc_from_posix_time(posix_time + off_day * SECS_PER_DAY + offset_sec,
195-
&tm->tm_year, &tm->tm_mon, &tm->tm_mday,
196-
&tm->tm_hour, &tm->tm_min, &tm->tm_sec)) {
194+
if (!utc_from_posix_time(
195+
posix_time + (int64_t)off_day * SECS_PER_DAY + offset_sec,
196+
&tm->tm_year, &tm->tm_mon, &tm->tm_mday, &tm->tm_hour, &tm->tm_min,
197+
&tm->tm_sec)) {
197198
return 0;
198199
}
199200
tm->tm_year -= 1900;

Sources/CCryptoBoringSSL/crypto/bio/bio.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,13 @@ int BIO_write_all(BIO *bio, const void *data, size_t len) {
192192
}
193193

194194
int BIO_puts(BIO *bio, const char *in) {
195-
return BIO_write(bio, in, strlen(in));
195+
size_t len = strlen(in);
196+
if (len > INT_MAX) {
197+
// |BIO_write| and the return value both assume the string fits in |int|.
198+
OPENSSL_PUT_ERROR(BIO, ERR_R_OVERFLOW);
199+
return -1;
200+
}
201+
return BIO_write(bio, in, (int)len);
196202
}
197203

198204
int BIO_flush(BIO *bio) {

Sources/CCryptoBoringSSL/crypto/bio/fd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static int fd_free(BIO *bio) {
158158
static int fd_read(BIO *b, char *out, int outl) {
159159
int ret = 0;
160160

161-
ret = BORINGSSL_READ(b->num, out, outl);
161+
ret = (int)BORINGSSL_READ(b->num, out, outl);
162162
BIO_clear_retry_flags(b);
163163
if (ret <= 0) {
164164
if (bio_fd_should_retry(ret)) {
@@ -170,7 +170,7 @@ static int fd_read(BIO *b, char *out, int outl) {
170170
}
171171

172172
static int fd_write(BIO *b, const char *in, int inl) {
173-
int ret = BORINGSSL_WRITE(b->num, in, inl);
173+
int ret = (int)BORINGSSL_WRITE(b->num, in, inl);
174174
BIO_clear_retry_flags(b);
175175
if (ret <= 0) {
176176
if (bio_fd_should_retry(ret)) {

Sources/CCryptoBoringSSL/crypto/bio/socket.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static int sock_read(BIO *b, char *out, int outl) {
101101
#if defined(OPENSSL_WINDOWS)
102102
int ret = recv(b->num, out, outl, 0);
103103
#else
104-
int ret = read(b->num, out, outl);
104+
int ret = (int)read(b->num, out, outl);
105105
#endif
106106
BIO_clear_retry_flags(b);
107107
if (ret <= 0) {
@@ -113,13 +113,11 @@ static int sock_read(BIO *b, char *out, int outl) {
113113
}
114114

115115
static int sock_write(BIO *b, const char *in, int inl) {
116-
int ret;
117-
118116
bio_clear_socket_error();
119117
#if defined(OPENSSL_WINDOWS)
120-
ret = send(b->num, in, inl, 0);
118+
int ret = send(b->num, in, inl, 0);
121119
#else
122-
ret = write(b->num, in, inl);
120+
int ret = (int)write(b->num, in, inl);
123121
#endif
124122
BIO_clear_retry_flags(b);
125123
if (ret <= 0) {

0 commit comments

Comments
 (0)