Skip to content

Validate first RTP header extensions and honor explicit profiles - #381

Draft
Awuqing wants to merge 1 commit into
pion:mainfrom
Awuqing:fix/first-extension-encoding
Draft

Awuqing wants to merge 1 commit into
pion:mainfrom
Awuqing:fix/first-extension-encoding

Conversation

@Awuqing

@Awuqing Awuqing commented Oct 24, 2026

Copy link
Copy Markdown

The first Header.SetExtension call can select the one-byte format for IDs
above 14, accept invalid IDs or lengths, and serialize a different extension
than the caller requested. SetExtensionWithProfile also ignores the requested
profile when the header has no extensions.

Select the automatic profile from both the ID and payload length, and
validate before mutating the header. Honor an explicit first profile and
validate existing extensions before converting formats. Reject empty
one-byte payloads through the shared validator used by Header and
OneByteHeaderExtension.

The first-extension validation overlaps with the earlier, closed #374 by
@RaphaelFakhri and the behavior discussed in #255. This patch also covers the
explicit-profile first call and invalid format conversions. No dependency
or exported API changes are included.

Validation on Go 1.26.5 / darwin-arm64:

  • Added wire round-trip and unchanged-on-error regressions. On main
    9a8f935, 14 of 20 table cases fail, as does the empty one-byte payload test.
  • go test -race -count=1 -timeout=3m ./... passes with the patch.
  • golangci-lint 2.10.1: 0 issues.

The shared validator has a targeted cyclop suppression because enforcing
the missing minimum length brings its complexity from 10 to 11.

Choose the initial format from both ID and length, validate before
mutation, and honor an explicitly requested profile on the first call.
Reject empty one-byte payloads and invalid profile conversions.

Add wire round-trip and unchanged-on-error regression tests.
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