Giter Site home page Giter Site logo

Comments (4)

hannesm avatar hannesm commented on June 15, 2024

Thanks for the report, from the documentation in the Int32 module, I read "The result is unspecified if [y < 0] or [y >= 32]." (where shift_right_logical x y is considered) --> the calling code (this ipaddr library) needs to treat y = 32 specially. Since you already found a reproduction test case, it would be nice to add it to the test suite in lib_test -- and at the same time look into the IPv6 Prefix module which may repeat a similar issue.

from ocaml-ipaddr.

verbosemode avatar verbosemode commented on June 15, 2024

I also ran some manual tests for IPv6 and the behavior looks correct. mem calls mask, which in turn calls V4.mask with the prefix length as argument. The latter returns 0l for prefix length of zero and bellow.

    # Ipaddr.V6.Prefix.mem (Ipaddr.V6.of_string_exn "2001:db8:c0ff:ee::1") 
           (Ipaddr.V6.Prefix.of_string_exn "::/0");;
    - : bool = true

I'll see if we can adapt the procedure of the v6 code to v4 and open a PR with the tests as you've suggested.

from ocaml-ipaddr.

hannesm avatar hannesm commented on June 15, 2024

thanks for looking into this @verbosemode -- looks like the V6 code is fine and doesn't need changes.
It would be great to have (a) failing tests for Ipv4.Prefix.mem (b) a fix for the issue (by handling 32 in a special way). If you need a hand (or further discussion / pointers), please let me know. We can as well look further into fixing this via IRC/XMPP.

from ocaml-ipaddr.

verbosemode avatar verbosemode commented on June 15, 2024

The undefined behavior of shift_right_logical seems to manifest only in the toplevel or when explicitly compiling to bytecode.

I've created PR #98 to fix the issue and added some tests for V4.Prefix.mem. The existing tests used Prefix.mem, which in turn calls V6.Prefix.mem and might not hit code in V4.Prefix.mem.

from ocaml-ipaddr.

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.