Giter Club home page Giter Club logo

Comments (5)

ckirsch avatar ckirsch commented on May 24, 2024

@maroneze Thanks a lot for pointing this out. The issue indeed has educational value. @ChristianMoesl did smalloc and will look into a fix. @ChristianMoesl I think, it is best to exit if initialization does not go through.

from selfie.

maroneze avatar maroneze commented on May 24, 2024

For completeness, the same thing might happen with character_buffer (print <- print_format1 <- printf1 called if the first smalloc() fails); exiting early should avoid both issues.

from selfie.

ChristianMoesl avatar ChristianMoesl commented on May 24, 2024

write() could also be used for this error message. However, selfie_name could not be printed in this case and the length of the printed error message would have to be a multiple of 8. (double-word alignment)

from selfie.

ckirsch avatar ckirsch commented on May 24, 2024

@maroneze If you are interested in doing that please feel free to submit a PR. Keep in mind though that we need simple, educational code to be able to pull any PR. Many thanks!

from selfie.

maroneze avatar maroneze commented on May 24, 2024

I proposed a PR, but not sure it is good enough, so feel free to dismiss it if you wish.

On the same kind of warnings, I have a few other issues with my analysis, mostly due to mismatches between the strict C semantics and the hardware model; for instance, when comparing strings such as "-c" (during argument parsing), the code in load_character, namely *((uint64_t*) s + a), implicitly assumes that the string s has at least 8 bytes, otherwise the memory access is invalid. This is more of a portability issue, and I don't have any suggestions other than padding the string with \0s (possibly with some macro).

And finally, function touch dereferences uninitialized memory (just after calling smalloc) using a type other than char, which in theory could trigger some trap representation and cause undefined behavior. Once again, this is more on the theoretical side, and probably not a real issue.

I'll try to identify some more "concerning" issues in the future and report them if I find anything. Just reported these here in case some zealous C language lawyer might wonder about them.

from selfie.

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.