Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misplaced parentheses in cork_ipv6_is_valid_network #171

Open
SparksDJ opened this issue Oct 24, 2021 · 0 comments
Open

Misplaced parentheses in cork_ipv6_is_valid_network #171

SparksDJ opened this issue Oct 24, 2021 · 0 comments

Comments

@SparksDJ
Copy link

When using ipsetbuild from libcorkipset, I found that all IPv6 addresses with a CIDR were being reported as errors (unless --loose-cidr was used). I eventually found the error in cork_ipv6_is_valid_network in libcork/core/ip-address.c : two closing parentheses have been misplaced. Lines 455 and 456 should be:

return (CORK_UINT64_BIG_TO_HOST(addr->_.u64[0]) & cidr_mask[0] == 0) &&
       (CORK_UINT64_BIG_TO_HOST(addr->_.u64[1]) & cidr_mask[1] == 0);

(The error would not be apparent in a big-endian architecture.)

I have tested this change by building a local version, and I am satisfied that it works.

As an aside, I also changed lines 441 and 442 to

return true;

since I regard a /128 on an IPv6 address (and /32 on an IPv4 address) as a no-operation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant