Open
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue with the NAS-Filter-Rule attribute when the rule value size exceeds the attribute size by aggregating multiple value pairs into a temporary buffer before output.
- Introduces a rule_buffer and rule_len to accumulate rule data.
- Replaces iteration over vp with a new pointer (current) and processes the buffered data in chunks with appropriate header resets.
- Adjusts pointer assignments to properly update the VALUE_PAIR pointer.
Comments suppressed due to low confidence (1)
src/lib/radius.c:1690
- [nitpick] The flag 'zero' is ambiguous; consider renaming it to 'insert_separator' to clarify its purpose of indicating when a separator byte should be added between concatenated rules.
zero = false;
Comment on lines
+1645
to
1651
| uint8_t rule_buffer[1024] = {0}; | ||
| size_t rule_len = 0; | ||
| VALUE_PAIR *current = vp; | ||
|
|
||
| attr[0] = PW_NAS_FILTER_RULE; | ||
| attr[1] = 2; | ||
| p = ptr + 2; | ||
|
|
||
| while (vp && !vp->da->vendor && (vp->da->attr == PW_NAS_FILTER_RULE)) { | ||
| if ((p + zero + vp->vp_length) > end) { | ||
| while (current && !current->da->vendor && (current->da->attr == PW_NAS_FILTER_RULE)) { | ||
| if ((rule_len + current->vp_length + 1) >= sizeof(rule_buffer)) { | ||
| break; |
There was a problem hiding this comment.
Using a fixed-size rule_buffer may silently truncate data when the accumulated length exceeds its capacity; consider implementing explicit error logging or dynamic buffer resizing to handle such cases.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes NAS-Filter-Rule attribute when the size of the value is bigger than the attribute size.