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

Frame size is now 24bit. Decode exception must be adjusted #17

Merged
merged 1 commit into from Nov 29, 2014

Conversation

mad-p
Copy link
Collaborator

@mad-p mad-p commented Sep 22, 2014

Additional frame size fixes.

@mad-p mad-p mentioned this pull request Sep 22, 2014
@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 72ff149 on lepidum:frame-size-test-fix into 61db3ee on igrigorik:master.

@@ -238,7 +238,7 @@
it "should raise connection error on decode exception" do
@conn << f.generate(SETTINGS)
frame = f.generate(HEADERS.dup)
frame[2] = 0.chr
frame[3] = 0.chr
Copy link
Owner

Choose a reason for hiding this comment

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

Hmm, are you sure? You're setting flags to 0x0..

  • [0,1] = 8+16bits (length)
  • [2] = type
  • [3] = flags

Or, am I missing something? Also, as an aside, some of these tests could definitely use some refactoring :)

@mad-p
Copy link
Collaborator Author

mad-p commented Sep 23, 2014

Hmm. In this code, frame is an octet string. frame[3] is type.

Setting type to zero (DATA) causes an exception
"receiving a DATA frame for unopened stream".

We should explicitly send DATA frame, rather than modify HEADERS octets.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 0f25817 on lepidum:frame-size-test-fix into 61db3ee on igrigorik:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 2c196cf on lepidum:frame-size-test-fix into 61db3ee on igrigorik:master.

@igrigorik
Copy link
Owner

Hmm, not sure about this one either. We already have a test for "error if first frame is not SETTINGS":
https://github.com/lepidum/http-2/blob/frame-size-test-fix/spec/connection_spec.rb#L11

The intent of this test was to test a decode exception - i.e. a malformed frame that contains bogus or invalid data.

@mad-p
Copy link
Collaborator Author

mad-p commented Sep 24, 2014

I agree.

How can we craft a "malformed frame"?

  • SETTINGS with stream_id != 0 (I think this best fits)
  • PING, PRIORITY, WINDOW_UPDATE, RST_STREAM with wrong payload size (We have to implement these validations anyway)
  • HEADERS with bad opcodes (It depends on HPACK version)

@mad-p
Copy link
Collaborator Author

mad-p commented Sep 24, 2014

Hmm.. There seems no validations on incoming frames in framer.rb.
Should we implement those before attacking this test?

I might mock framer.parse to raise an error (instead of feeding crafted octets).

@conn.instance_eval{@framer}.should_receive(:parse).and_raise(CompressionError.new)

@igrigorik
Copy link
Owner

I think the wording of current test is misleading. We're testing connection-level logic in this set of tests, and framing errors should be handled elsewhere. I propose we:

  • Update "should raise connection error on encode exception" > "should raise connection error on send of invalid frame"
  • Update "should raise connection error on decode exception" > "should raise connection error on receipt of invalid frame"

Within the latter test, we can set SETTINGS with stream ID != 0.

Then, independent of the above, we can add some specs (and logic) for frame decode sanity checking:

Right now we assume that we receive well-formed frames.. which is optimistic. :)

@igrigorik igrigorik mentioned this pull request Oct 14, 2014
@igrigorik
Copy link
Owner

bump.. we should probably fix this. @mad-p did my last comment make sense?

@igrigorik igrigorik merged commit 2c196cf into igrigorik:master Nov 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants