Comments (4)
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.
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.
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.
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)
- test B128 fails on i586 HOT 1
- `V6.to_int64` is broken if the 2nd or 4th 32-bit integer in an IPv6 address is greater than `2^31-1` HOT 16
- classify routable and non-routable addresses HOT 2
- License file is missing HOT 1
- Include cmti files. HOT 1
- Ipaddr.to_domain_name returns an empty label
- API inconsistency: no Macaddr.pp_hum HOT 1
- ipaddr 2.7.1 opam install failed HOT 2
- missing dependency HOT 2
- Inconsistency in V4.Prefix.of_string / V6.Prefix_of_string regarding trailing chars HOT 1
- Short CIDR notation HOT 2
- Is Dune broken or am I stupid? HOT 3
- Handle RFC 4007: IPv6 zone indices for link-local scoped addresses HOT 2
- This requires Dune >= 1.6 HOT 3
- Clarify bytestring conversion docstrings HOT 5
- index out of bounds with Ipaddr.V6.of_string
- docstring comment looks wrong
- can't install [email protected] because of bug in [email protected] HOT 2
- is there a type to store "ip in this network"? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ocaml-ipaddr.