Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

tls_wrap: parse tls session ticket extension #5882

Closed
wants to merge 1 commit into from

Conversation

indutny
Copy link
Member

@indutny indutny commented Jul 21, 2013

And, if present and non-empty, don't invoke resumeSession callback.

fix #5872

@indutny
Copy link
Member Author

indutny commented Jul 21, 2013

/cc @bnoordhuis @isaacs @bajtos

// Parse known extensions
while (ext_off < avail) {
// Extension OOB
if (avail - ext_off < 3)
Copy link

Choose a reason for hiding this comment

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

You are reading 4 bytes below, I would expect the condition to be avail - ext_off < 4.

@indutny
Copy link
Member Author

indutny commented Jul 23, 2013

Thanks, again! All fixed. /cc @isaacs @bnoordhuis

@bajtos
Copy link

bajtos commented Jul 24, 2013

For what it's worth, the change LGTM. Can it be back-ported to v0.10 too?

@indutny
Copy link
Member Author

indutny commented Jul 25, 2013

@bajtos no way for backporting it, I promised to not touch clienthello parser in node_crypto.cc in any version.

@bajtos
Copy link

bajtos commented Jul 25, 2013

@bajtos no way for backporting it, I promised to not touch clienthello parser in node_crypto.cc in any version.

I saw this coming after Ben's comment in the other issue :)

If we can disable TLS session tickets in cluster workers, then these extra resumeSession calls at least won't cause slowdowns, since the session lookup is fast in single-process case.

And, if present and non-empty, don't invoke `resumeSession` callback.

fix nodejs#5872
return ParseFinish();

uint16_t cipher_len = (data[cipher_offset] << 8) +
data[cipher_offset + 1];
Copy link
Member

Choose a reason for hiding this comment

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

Style?

uint16_t cipher_len =
    (data[cipher_offset] << 8) + data[cipher_offset + 1];

Is a little more idiomatic. For that matter, you could write it like this:

uint16_t cipher_len =
    data[cipher_offset] * 256 + data[cipher_offset + 1];

Then you don't have to use parentheses everywhere. Just food for thought. :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, its mostly style issues :) I like having powers of two in code, though I know value of 2^8, 2^16 and 2^24.

Copy link
Member

Choose a reason for hiding this comment

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

Also, data[cipher_offset + 1] looks like it could be an out-of-bounds read.

@bnoordhuis
Copy link
Member

Some comments, mostly LGTM.

@bnoordhuis
Copy link
Member

One more comment (I also mentioned this on IRC): the parser is calling ParseFinish() in a lot of places when the input is malformed. Shouldn't that be (the currently non-existent) ParseError()?

@indutny
Copy link
Member Author

indutny commented Aug 1, 2013

Thanks, landed with fixes in dda22a5.

@indutny indutny closed this Aug 1, 2013
@indutny indutny deleted the fix/gh-5872 branch August 1, 2013 12:07
@indutny
Copy link
Member Author

indutny commented Aug 1, 2013

About ParseError(): I'm calling ParseFinish() to let OpenSSL deal with any trouble or security problem that might be related to incorrect data in ClientHello. Therefore, there is no need in function that'll report errors and figure out what exactly wrong, as its already implemented in openssl.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants