GithubHelp home page GithubHelp logo

Comments (8)

frol avatar frol commented on May 25, 2024 1

Nope, we still need to address it

from borsh-rs.

frol avatar frol commented on May 25, 2024

Good call! Indeed, this unsafe is not playing well:

} else if size_of::<T>() == 0 {
let mut result = Vec::new();
result.push(T::deserialize(buf)?);
let p = result.as_mut_ptr();
unsafe {
forget(result);
let len = len.try_into().map_err(|_| ErrorKind::InvalidInput)?;
let result = Vec::from_raw_parts(p, len, len);
Ok(result)
}

@ailisp It seems that you have some experience with this area (near/borsh#41). Do you have the capacity to work on this issue?

from borsh-rs.

evgenykuzyakov avatar evgenykuzyakov commented on May 25, 2024

I think there is no need to optimize zero size structure, so let's just use a loop here to create it. Obviously it would add an ability to create an a very large loop that wouldn't be limited by the input data size.

from borsh-rs.

nearmax avatar nearmax commented on May 25, 2024

Can this be closed @frol @matklad ?

from borsh-rs.

dtolnay avatar dtolnay commented on May 25, 2024

Given that the repro code in #19 (comment) still compiles and still segfaults, and the bad unsafe in #19 (comment) is still present in master, I would say no.

from borsh-rs.

westy92 avatar westy92 commented on May 25, 2024

FYI this issue is now in the GitHub Advisory Database with Moderate severity: GHSA-fjx5-qpf4-xjf2

Also in RUSTSEC: https://rustsec.org/advisories/RUSTSEC-2023-0033.html

Is there a plan to address this?

from borsh-rs.

frol avatar frol commented on May 25, 2024

@westy92 I will be happy to review a pull request. The issue is hypothetical, and you really need to setup yourself into a trouble to exercise it, so given the limited resources (no active contributors to this project), it is not going to be fixed any time soon unless someone from the community contributes the fix.

from borsh-rs.

frol avatar frol commented on May 25, 2024

A vector of zero-sized types is pointless in the context of serialization/deserialization in my opinion, so I believe the best thing is to just forbid collections of zero-size elements (#136 (comment)). I am wondering if there is a way to do it through the type system (in the worst case, we will do it at runtime).

from borsh-rs.

Related Issues (20)

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.