Skip to content

Add bounds check in Remember to prevent potential bof panic #256

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chengpeng-wang
Copy link

Hi, I found the function Remember in the file sample/user.go does not check the lengths of the parameters keys and values. If the number of keys is greater than the one of values, the buffer access at line 103 would cause bof panic. This patch adds a length check in the Remember function to avoid this bof panic.

Although current test cases use matching lengths, adding this check improves robustness and makes the assumption explicit, which can help avoid unexpected panics if the function is reused elsewhere.

Let me know if you'd prefer returning an error instead of logging a fatal error—happy to adjust.

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.

1 participant