Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto: build warning fixes #10142

Closed
wants to merge 2 commits into from
Closed
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1536,8 +1536,9 @@ static Local<Object> X509ToObject(Environment* env, X509* cert) {
String::kNormalString, mem->length));
(void) BIO_reset(bio);

BN_ULONG exponent_word = BN_get_word(rsa->e);
BIO_printf(bio, "0x%lx", exponent_word);
unsigned long exponent = // NOLINT(runtime/int)
static_cast<unsigned long>(BN_get_word(rsa->e)); // NOLINT(runtime/int)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct per se on 32 bits architectures where long is 32 bits and BN_ULONG is a 64 bits unsigned long long.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix this tomorrow.

BIO_printf(bio, "0x%lx", exponent);

BIO_get_mem_ptr(bio, &mem);
info->Set(env->exponent_string(),
Expand Down
6 changes: 5 additions & 1 deletion src/node_crypto_clienthello.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#include "node_crypto_clienthello-inl.h"
#include "node_buffer.h" // Buffer

// FUTURE TODO export maximum TLS ticket size:
static const size_t kTLSTicketSizeMask = 0xFFFF;

namespace node {

void ClientHelloParser::Parse(const uint8_t* data, size_t avail) {
Expand Down Expand Up @@ -146,7 +149,8 @@ void ClientHelloParser::ParseExtension(const uint16_t type,
ocsp_request_ = 1;
break;
case kTLSSessionTicket:
tls_ticket_size_ = len;
// TBD POSSIBLE DATA LOSS:
tls_ticket_size_ = static_cast<uint16_t>(len & kTLSTicketSizeMask);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@indutny Is there a reason tls_ticket_size_ is of type uint16_t instead of size_t?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's how much bits it occupies in binary representation. I don't have any strong feelings about making it wider, though.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is what I gather from a quick grep: tls_ticket_size_ stores a ticket size and tls_ticket_ stores a pointer to some ticket information but they are only used to determine a hello.has_ticket_ boolean value. I start to wonder if we could replace the tls_ticket_ and tls_ticket_size_ members with a member like has_valid_tls_ticker_ to avoid keeping more state than necessary?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tls_ticket_ = data + len;
break;
default:
Expand Down