Giter Club home page Giter Club logo

Comments (5)

b-carr avatar b-carr commented on August 12, 2024

I think we want to handle this both in the seal/unseal executable main functions, (early exit with a message if you hand it a size 0 file) and in the library seal/unseal library functions.

from kmyth.

b-carr avatar b-carr commented on August 12, 2024

Looking more closely at the code, I think by putting the check in kmyth_wrap_input in src/util/tpm2_kmyth_seal.c is the best place from the library perspective.

The src/seal/main.c executable should also check before doing all the TPM work.

from kmyth.

wmillstone avatar wmillstone commented on August 12, 2024

The first fix seems easy enough, but for the check in src/seal/main.c it looks like we would want to make a call to read_arbitrary_file() to get the data length. This is already done later on, in kmyth_wrap_input in src/util/tpm2_kmyth_seal.c. Doing this twice seems like it may be redundant if we are not passing along the output values.

from kmyth.

b-carr avatar b-carr commented on August 12, 2024

That's a good point. For now let's just fix kmyth_wrap_input. I still don't like the idea of doing all that TPM work just to find out the file has zero size, but it's going to be a bigger job to do the filesize check reasonably, so we can keep it in mind for future work if we decide it's worthwhile.

from kmyth.

PeterHamilton avatar PeterHamilton commented on August 12, 2024

I'm a bit late to the discussion but I figured this was relevant.

I'm adding error handling to read_arbitrary_file in src/util/tpm2_kmyth_io.c. A file size of 0 bytes may cause malloc to return NULL, which is indistinguishable from an allocation failure. Right now (with my edits) this returns 1, which would get caught and handled right before the fix added in #26, resurrecting the original issue.

I can change this so that read_arbitrary_file just short circuits and returns early when it encounters a 0 byte file, so that the fix in #26 still applies as expected. Would that be the preferred error flow here?

On the opposite end of spectrum, what is the maximum file size that should be supported? We could just rely on malloc erroring out in that case but that may not be sufficient. Is there a reasonable maximum threshold? Or is this out-of-scope here anyway since the user is supplying the file?

from kmyth.

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.