Skip to content

Misplaced parentheses in cork_ipv6_is_valid_network #171

@SparksDJ

Description

@SparksDJ

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions