Code Monkey home page Code Monkey logo

bcder's People

Contributors

alexanderband avatar dovreshef avatar drike avatar lvkv avatar maertsen avatar nocduro avatar outurnate avatar partim avatar ties avatar wk avatar ximon18 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bcder's Issues

format!("{}",Oid) hangs forever

#[test]
pub fn test_oid_format(){
let oid= Oid(&[85, 29, 19]);
assert_eq!("2.5.29.19",format!("{}",oid).as_str()); //never finished per infinite loop in fmt implemntation
}

Avoid stack overflow when parsing nested octet strings.

In BER mode, OCTET STRINGs can be encoded in a nested fashion. Currently, you can blow up the stack with a well-crafted structure. Either find a way to parse them without recursion or limit the recursion depth and bail out.

int check_head rejects valid ASN.1 encoding

In https://github.com/NLnetLabs/bcder/blob/master/src/int.rs#L244 there is a check to ensure that an integer is encoded in the smallest possible octets number.

The problem is that under BER it is valid to have an integer that is encoded in the most efficient way, and sadly it happens a lot in the type of packets that I'm decoding...

For example, the following code

use bcder::Mode;

fn main() {
    let u16_1: &[u8] = b"\x02\x03\x00\xff\xf8";
    let u16_2: &[u8] = b"\x02\x02\xff\xff";

    let decode = |val| {
        Mode::Ber.decode(val, |cons| cons.take_u16())
    };

    println!("{:?}", decode(u16_1));
    println!("{:?}", decode(u16_2));
}

will print

Ok(65528)
Err(Malformed)

Even though the second slice is also a valid ASN.1 integer (0..max).

bytes 0.5 compatibility

I'm currently in the process of updating packaged crates for futures 0.3/tokio 0.2 compatibility in Debian, which also entails updating to bytes 0.5.

Unfortunately bytes 0.4->0.5 does entail some breaking changes, and bcder's Captured/CapturedWriter are affected as well:

call in Captured::extend

error[E0599]: no method named `extend_from_slice` found for type `&'a mut bytes::bytes::Bytes` in the current scope
   --> src/captured.rs:197:16
    |
197 |         self.0.extend_from_slice(buf);
    |                ^^^^^^^^^^^^^^^^^ help: there is a method with a similar name: `clone_from_slice`

I am not sure whether this means that Captured needs to switch over to BytesMut or whether there is a simpler solution. tokio-rs/bytes#368 and tokio-rs/bytes#350 might also be related.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.