Skip to content

Commit f540887

Browse files
committed
Use OPENSSL_cleanse where appropriate
1 parent 63cc957 commit f540887

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

crypto/bio/bio_mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static long mem_ctrl(BIO *bio, int cmd, long num, void *ptr) {
217217
b->data -= b->max - b->length;
218218
b->length = b->max;
219219
} else {
220-
OPENSSL_memset(b->data, 0, b->max);
220+
OPENSSL_cleanse(b->data, b->max);
221221
b->length = 0;
222222
}
223223
}

crypto/bio/bio_socket_test.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ static void test_send_receive(bssl::UniquePtr<BIO> &sender_bio,
518518

519519
// Receive a message
520520
char buff[1024];
521+
OPENSSL_cleanse(buff, sizeof(buff));
521522
ASSERT_EQ((int)strlen(kTestMessage) + 1,
522523
BIO_read(receiver_bio.get(), buff, sizeof(buff)))
523524
<< LastSocketError();
@@ -539,6 +540,7 @@ static void test_puts_receive(bssl::UniquePtr<BIO> &sender_bio,
539540

540541
// Receive a message.
541542
char buff[1024];
543+
OPENSSL_cleanse(buff, sizeof(buff));
542544
// `BIO_puts` does not send the \0 byte at the end of the string.
543545
ASSERT_EQ((int)strlen(kTestMessage),
544546
BIO_read(receiver_bio.get(), buff, sizeof(buff)))

crypto/bio/socket_helper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ int bio_ip_and_port_to_socket_and_addr(int *out_sock,
5151

5252
*out_sock = -1;
5353

54-
OPENSSL_memset(&hint, 0, sizeof(hint));
54+
OPENSSL_cleanse(&hint,sizeof(hint));
5555
hint.ai_family = AF_UNSPEC;
5656
hint.ai_socktype = SOCK_STREAM;
5757

@@ -72,7 +72,7 @@ int bio_ip_and_port_to_socket_and_addr(int *out_sock,
7272
if ((size_t) cur->ai_addrlen > sizeof(struct sockaddr_storage)) {
7373
continue;
7474
}
75-
OPENSSL_memset(out_addr, 0, sizeof(struct sockaddr_storage));
75+
OPENSSL_cleanse(out_addr, sizeof(struct sockaddr_storage));
7676
OPENSSL_memcpy(out_addr, cur->ai_addr, cur->ai_addrlen);
7777
*out_addr_length = cur->ai_addrlen;
7878

0 commit comments

Comments
 (0)