Repository navigation
Conversation
…ER input read_ber / read_ber_length / parse_ber_object assumed the stream always had the bytes the length field promised. A server (or anything on the wire) sending a truncated PDU made Net::LDAP#bind raise NoMethodError (undefined method '<=' / 'each_byte' / 'unpack' for nil) or RangeError, which callers that rescue Net::LDAP::Error or Net::BER::BerError never see. Zero-length INTEGER and OBJECT IDENTIFIER content raised the same way. All these cases now raise Net::BER::BerError. Adds tests. Made by SLIME
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A truncated LDAP response makes
Net::LDAP#bind(and any search) raiseNoMethodErrorinstead of a BER/LDAP error. Reproduced end to end against a socket server that answers the bind with a cut-off PDU (net-ldap 0.21.0):30NoMethodError: undefined method '<=' for nil(ber_parser.rb:138)30 84NoMethodError: undefined method 'each_byte' for nil(:146)02 00/06 00NoMethodErrorfor nil in integer / OID parsingRangeError: bignum too big to convert into 'long'read_beralready carries a TODO that it "can throw TypeErrors and other nasties" on short reads. This makes it raiseNet::BER::BerErrorin those places: end of data inside the length, fewer content bytes than the length promises, empty INTEGER/OID content, and a content length above 2^31-1. Valid input is unchanged (full suite: 220 tests green; the newTestBERMalformedInputfails on master and passes here).Found by mutating valid BER with a small fuzzer and watching for exception classes other than BerError.
Made by SLIME