Commit Graph

83 Commits

Author SHA1 Message Date
James Coglan ba6c47dd77 Extract the Java integer parsing into a helper class. 2017-03-26 12:08:49 +01:00
James Coglan 92f4bdfb06 Use the bounds_check function to check preconditions for reading and writing uint16/uint64. 2017-03-15 09:56:04 +00:00
James Coglan 609d4feac0 Make the pointer-clearing macro shouty. 2017-03-15 01:55:01 +00:00
James Coglan 8818e7e176 Remove an unused iteration macro from queue.c. 2017-03-15 01:54:46 +00:00
James Coglan 8fab2188c7 Update the valgrind script to include chunk.c and a callback for reserializing incoming messages, to test the unparser is not leaking. 2017-03-14 22:03:30 +00:00
James Coglan c22c952fb6 Rename ReadBuffer to StreamReader to match the Ruby version. 2017-03-14 21:59:50 +00:00
James Coglan 29dec87660 Wrap all buffers in the C implementation in an opaque struct that records the length of the buffer and an API that checks the offsets of common buffer operations. 2017-03-14 21:41:33 +00:00
James Coglan 5ba7910b17 Macros are SHOUTY. 2017-03-07 09:46:52 +00:00
James Coglan f95895f729 Check for hitting the max message size and max read buffer capacity without using additions that could overflow. 2017-03-07 09:42:23 +00:00
James Coglan 4564736fde Bring close frame handling into line between parser implementations. 2017-03-06 21:12:27 +00:00
James Coglan d488d3b050 Remove the unused wsd_Observer_on_frame() callback facility. 2017-03-04 12:35:01 +00:00
James Coglan 61fabc7337 Integrate hooks for calling valid_frame_rsv? into the native extensions, so that WebSocket extension modules can override RSV validation. 2017-03-04 12:31:55 +00:00
James Coglan 183674c99f Extract helpers for constructing JRuby values into their own class. 2017-03-04 00:35:36 +00:00
James Coglan 33c930be34 Check that control frames are smaller than 125, not larger. 2017-03-03 22:20:36 +00:00
James Coglan 6706fe31ce In order to correctly serialise the length of long frames, the Frame.length field should be a long and bitshifting should be done with >>>. This necessitates various casts to ints, which is what byte[] sizes are measured in. 2017-03-01 18:11:20 +00:00
James Coglan 8e307f3429 Create a new Message when the opcode is binary. This was responsible for a NullPointerException when emitting a message. 2017-03-01 18:08:35 +00:00
James Coglan 79134ffade Adjust formatting in construction of first byte in Unparser. 2017-03-01 09:11:53 +00:00
James Coglan 2d60b40b94 Implement Unparser in Java and use the native unparser in native_spec.rb. 2017-03-01 00:57:20 +00:00
James Coglan 000f0b81fc Due to JRuby's limitation of only accepting 3 arguments on @JRubyMethod methods, we need to pack a few of the arguments to Unparser#frame() into an array. 2017-03-01 00:44:39 +00:00
James Coglan 8a43a2879a Tidy up the JRuby bindings using factory methods for Ruby types. 2017-02-27 23:50:51 +00:00
James Coglan ddcd43995c Port the parser to Java, passing all the unit tests. 2017-02-26 22:56:07 +00:00
James Coglan 5c15da3a32 Set up C extension for running tests through valgrind. 2017-01-05 23:49:44 +00:00
James Coglan 319275d07b Free the allocated Observer if allocating a Parser fails. 2017-01-05 22:26:48 +00:00
James Coglan bfcc911a81 Replace the Queue_scan function and callback with an external iterator that exposes the values. 2017-01-05 21:58:46 +00:00
James Coglan 914dadb973 Port the frame serializer to C. 2017-01-05 21:38:26 +00:00
James Coglan f36fe01a19 The parser opcode checking functions should take an opcode, not a Parser. 2016-12-31 17:57:37 +00:00
James Coglan 3f54340819 Add a C program to pass all the Autobahn test data through the parser directly, not via Ruby. We can use this to test the parser with Valgrind. 2016-12-31 16:05:47 +00:00
James Coglan ede6490add Refer to error messages as 'reasons' so as not to confuse them with WebSocket message structs. 2016-12-31 15:48:47 +00:00
James Coglan 99a6e459fe The parser should keep reading as long as the read length is the same as the required length; sometimes this is zero. 2016-12-29 11:28:18 +00:00
James Coglan 21bfd23f1a Implement basic RSV checking for the case when no extensions are active. 2016-12-29 01:55:23 +00:00
James Coglan 6ffb801dd1 Remove a redundant check for continuation frames when there's no initialised message. 2016-12-29 01:54:54 +00:00
James Coglan 97b497a520 Drop the old native extension and replace it with the new all-C parser. Replace the old masking code with a Ruby version, so that the Hybi class is pure Ruby. 2016-12-29 01:09:12 +00:00
James Coglan 524aa3f356 Add handling of close frames. 2016-12-29 00:34:36 +00:00
James Coglan 8eaae3a149 Implement hooks for ping/pong. 2016-12-28 18:04:27 +00:00
James Coglan ce21d26e48 Check the length of incoming frames, including checking what they would add to the total message size. 2016-12-28 16:35:05 +00:00
James Coglan 721644495b Implement the require_masking flag properly. 2016-12-28 16:14:52 +00:00
James Coglan d6ddd6eedc Implement some error handling: checking for non-final and too-long control frames, unmasked data, and continuation violations. 2016-12-28 15:59:25 +00:00
James Coglan ae62fc6322 Begin emitting native parser errors back to the driver, starting by handling invalid opcodes. 2016-12-28 15:25:44 +00:00
James Coglan fbd22b99aa Make wsd_Queue_destroy() for-loop simpler and remove an unused variable warning. 2016-12-27 14:54:18 +00:00
James Coglan 8366d2790a Move declarations to the top of WebSocketParser callbacks. 2016-12-27 14:50:22 +00:00
James Coglan 01e8bd904d Wrap calls out to the Ruby driver and user callbacks in rb_protect. 2016-12-27 14:39:01 +00:00
James Coglan 4e747733a3 Begin wiring the C parser up to a Ruby driver. Driver::Native is currently a hollowed-out copy of Driver::Hybi with the parsing code removed. 2016-12-27 12:26:59 +00:00
James Coglan d5b2af3782 Make the Observer and Parser structs opaque. 2016-12-26 16:38:37 +00:00
James Coglan abd0a9372c Make the Queue structs opaque. 2016-12-26 15:59:31 +00:00
James Coglan 94317d4461 Make the ReadBuffer structs opaque. 2016-12-26 15:17:05 +00:00
James Coglan 4a79ae4eea Remove a couple of demeter violations: the parser accessing buffer->capacity, and buffer reaching into its queue via queue->head->value. 2016-12-26 12:55:46 +00:00
James Coglan 10f180e9f1 Use a macro for freeing then nulling a pointer, and make sure all destructors null out pointers where appropriate. 2016-12-26 12:14:51 +00:00
James Coglan fd4bbb0c12 Don't check if pointers are not NULL before freeing them.
Freeing a null pointer is a no-op and doesn't stop you double-freeing
things. What actually stops that is nulling out pointers after you've
freed what they point at.
2016-12-24 12:02:10 +00:00
James Coglan 5f1a789e3b Null out member pointers after freeing them in destroy() functions. 2016-12-24 11:02:00 +00:00
James Coglan 29321d3867 The 'masking' field of wsd_Parser is not needed; it's a serialisation setting not a parsing one. 2016-12-24 00:34:16 +00:00