Giter Club home page Giter Club logo

authenticode-parser's People

Contributors

plusvic avatar vthib avatar

Watchers

 avatar  avatar

Forkers

plusvic

authenticode-parser's Issues

Panic when parsing some PE files

The parser has started panicking with nightly rustc when file with SHA-256 af3f20a9272489cbef4281c8c86ad42ccfb04ccedd3ada1e8c26939c726a4c8e is scanned.

It looks like std::slice::from_raw_parts is now checking that the pointer it receives is not null. The documentation for this function says:

data must be non-null and aligned even for zero-length slices

Apparently, this wasn't enforced until now.

In line 130 in the snippet below, the signatures pointer passed to from_raw_parts is null when the file is scanned.

// Safety:
// The signatures field has type `*mut *mut sys::Authenticode`. It is safe to cast
// to `*mut Authenticode` because:
// - The Authenticode type is a transparent wrapper on a &sys::Authenticode
// - The `*mut sys::Authenticode` pointers in the array are guaranteed to be non-null
// (checked by auditing the C code).
let signatures = this.signatures.cast::<Authenticode>();
// Safety:
// - The signatures + count pair is guaranteed by the library to represent an array.
// - The lifetime of the slice is tied to the lifetime of self, so the memory cannot be
// freed before the slice is dropped.
unsafe { std::slice::from_raw_parts(signatures, this.count) }

The following comment doesn't hold true for this particular file:

 // - The `*mut sys::Authenticode` pointers in the array are guaranteed to be non-null 
 //   (checked by auditing the C code). 

This may be a bug in the C library, but I think its worth modifying this code to making it more robust.

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.