Skip to content

Commit

Permalink
Fixed template retreats
Browse files Browse the repository at this point in the history
  • Loading branch information
fooker committed Dec 14, 2017
1 parent d36f993 commit 583abb3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,10 @@ public OptionsTemplateRecordHeader(final ByteBuffer buffer) throws InvalidPacket
this.scopeFieldCount = uint16(buffer);

// Since Template IDs are used as Set IDs in the Sets they describe
if (this.templateId <= 255) {
if (this.templateId <= 255 && this.templateId != SetHeader.OPTIONS_TEMPLATE_SET_ID) {
throw new InvalidPacketException("Invalid template ID: %d", this.templateId);
}

if (this.fieldCount <= 0) {
throw new InvalidPacketException("Empty template");
}

if (this.scopeFieldCount > this.fieldCount) {
throw new InvalidPacketException("More scope fields than fields available: %d > %d", this.scopeFieldCount, this.fieldCount);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public SetHeader(final ByteBuffer buffer) throws InvalidPacketException {

// The Set ID values of 0 and 1 are not used, for historical reasons [RFC3954], values from 4 to 255 are
// reserved for future use.
if (this.setId < 256 && this.setId != 2 && this.setId != 3) {
if (this.setId < 256 && this.setId != TEMPLATE_SET_ID && this.setId != OPTIONS_TEMPLATE_SET_ID) {
throw new InvalidPacketException("Invalid set ID: %d", this.setId);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,9 @@ public TemplateRecordHeader(final ByteBuffer buffer) throws InvalidPacketExcepti
this.fieldCount = uint16(buffer);

// Since Template IDs are used as Set IDs in the Sets they describe
if (this.templateId <= 255) {
if (this.templateId <= 255 && this.templateId != SetHeader.TEMPLATE_SET_ID) {
throw new InvalidPacketException("Invalid template ID: %d", this.templateId);
}

if (this.fieldCount <= 0) {
throw new InvalidPacketException("Empty template");
}
}

@Override
Expand Down

0 comments on commit 583abb3

Please sign in to comment.