Skip to content

Reject invalid prefix lengths in native lookup methods - #92

Open
omrzk wants to merge 1 commit into
mjschultz:mainfrom
omrzk:fix/reject-invalid-native-prefixes-56
Open

omrzk wants to merge 1 commit into
mjschultz:mainfrom
omrzk:fix/reject-invalid-native-prefixes-56

Conversation

@omrzk

@omrzk omrzk commented Nov 16, 2026

Copy link
Copy Markdown

Invalid IPv4/IPv6 prefix lengths in native lookup and delete calls can return SystemError, KeyError, or an incorrect lookup result instead of ValueError. prefix_pton_ex returned its caller-supplied stack storage after prefix validation failed, even though it had not initialized that storage.

Keep the output pointer separate from the supplied storage so only a successfully constructed prefix is returned. Add public API coverage for CIDR and explicit prefix lengths across all seven methods, retained node data/iteration, valid host/default routes, and missing-prefix deletion.

Fixes #56.

Validation: compiled native extension; full pytest suite 85 passed, 1 skipped on Python 3.14; same suite 85 passed, 1 skipped using the Python fallback; both configured Flake8 checks pass. On unchanged main, the new tests produce 36 failures and 10 preservation passes with the compiled native backend. No native Windows/macOS/free-threaded run was performed.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

search_best returned NULL without setting an exception

1 participant