Skip to content

Commit d8da86f

Browse files
davidbennebeid
authored andcommitted
Miscellaneous size_t truncation fixes
Bug: 516 Change-Id: I3cc7e85687a29201a325b498eecf3694e0429ebc Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/60067 Commit-Queue: David Benjamin <[email protected]> Reviewed-by: Adam Langley <[email protected]> (cherry picked from commit 7e56051791944efa303930690a2089805385c983)
1 parent 17325c4 commit d8da86f

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

crypto/x509/x509_time_test.cc

+4-7
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,11 @@ TEST(X509TimeTest, TestCmpTime) {
296296
for (auto &test : kX509CmpTests) {
297297
SCOPED_TRACE(test.data);
298298

299-
ASN1_TIME t;
299+
bssl::UniquePtr<ASN1_STRING> t(ASN1_STRING_type_new(test.type));
300+
ASSERT_TRUE(t);
301+
ASSERT_TRUE(ASN1_STRING_set(t.get(), test.data, strlen(test.data)));
300302

301-
memset(&t, 0, sizeof(t));
302-
t.type = test.type;
303-
t.data = (unsigned char*) test.data;
304-
t.length = strlen(test.data);
305-
306-
EXPECT_EQ(test.expected, X509_cmp_time_posix(&t, test.cmp_time));
303+
EXPECT_EQ(test.expected, X509_cmp_time_posix(t.get(), test.cmp_time));
307304
}
308305
}
309306

ssl/test/async_bio.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ static int AsyncWrite(BIO *bio, const char *in, int inl) {
5959
return -1;
6060
}
6161

62-
if (!a->datagram && (size_t)inl > a->write_quota) {
63-
inl = a->write_quota;
62+
if (!a->datagram && static_cast<size_t>(inl) > a->write_quota) {
63+
inl = static_cast<int>(a->write_quota);
6464
}
6565
int ret = BIO_write(bio->next_bio, in, inl);
6666
if (ret <= 0) {
@@ -85,8 +85,8 @@ static int AsyncRead(BIO *bio, char *out, int outl) {
8585
return -1;
8686
}
8787

88-
if (!a->datagram && (size_t)outl > a->read_quota) {
89-
outl = a->read_quota;
88+
if (!a->datagram && static_cast<size_t>(outl) > a->read_quota) {
89+
outl = static_cast<int>(a->read_quota);
9090
}
9191
int ret = BIO_read(bio->next_bio, out, outl);
9292
if (ret <= 0) {

0 commit comments

Comments
 (0)