Skip to content

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

Open
chengpeng-wang wants to merge 1 commit intouber-go:mainfrom
chengpeng-wang:main
Open

Add bounds check in Remember to prevent potential bof panic#256
chengpeng-wang wants to merge 1 commit intouber-go:mainfrom
chengpeng-wang:main

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