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

Adding support starent attribute encoding and decoding #30

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

dc8-metaswitch
Copy link

Starent radius packet attribute length is 2 byte. While testing with decoding and encoding starent radius attribute, tinyradius was going infinite loop during decoding and failed to encode in case length more than 255. With this changes it now handles starent radius dictionary.

rhino added 3 commits December 9, 2019 08:46
…te Radius attribute length. It now supports encoding and decoding of radius packet has 2 bytes radius attribute length.

The library has also been tested well with starent radius dictionary (2 byte attribute length).

	modified:   src/main/java/org/tinyradius/attribute/RadiusAttribute.java
	modified:   src/main/java/org/tinyradius/attribute/VendorSpecificAttribute.java
	modified:   src/main/java/org/tinyradius/dictionary/AttributeType.java
	modified:   src/main/java/org/tinyradius/packet/RadiusPacket.java
if (attributeType < 0 || attributeType > 255)
throw new IllegalArgumentException("attribute type invalid: " + attributeType);
// Vendor specific attribute has values > 255 and < 1
/*if (attributeType < 0 || attributeType > 255)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer you remove the commented out code, not sure what is the purpose to leave it as commented out.

* @return attribute
*/
public byte[] write2ByteAttribute() {
if (getAttributeType() == -1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why checking for -1?

attr[2] = (byte) (data_length >> 8 & 0x0ff);
attr[3] = (byte) (data_length & 0x0ff);
System.arraycopy(attributeData, 0, attr, 4, attributeData.length);
return attr;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to see a unit test to verify previous and modified behavior?

@ctran ctran added the Reviewed label Oct 14, 2021
@ctran ctran force-pushed the master branch 3 times, most recently from 67019ad to 5526820 Compare February 1, 2022 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants