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

private: Policy.PolicyFromExtPolicy modifies existing policy. #4682

Open
tzaeschke opened this issue Jan 21, 2025 · 1 comment
Open

private: Policy.PolicyFromExtPolicy modifies existing policy. #4682

tzaeschke opened this issue Jan 21, 2025 · 1 comment

Comments

@tzaeschke
Copy link
Contributor

While porting the path policy language to JPAN, I came across this code in private/path/pathpol/policy.go:

policy := extPolicy.Policy

The first line in the methods takes the *Policy from the extPolicy and then (unless it is nil) modifies and returns it.
However, the comment on the function states that a new policy would be created and returned.
Moreover, this appears to be the only function in this module that allows modifying existing policies.

I suspect the first line is wrong and should instead copy the policy object.

Is that a bug?

@jiceatscion
Copy link
Contributor

I agree with you that it's pretty suspicious. It almost looks like extPolicy.Policy used to be a value and was changed to a pointer without sufficient consideration.

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

2 participants