Skip to content

Commit 9ebb627

Browse files
committed
patched v0.1.37
1 parent 7bb77ba commit 9ebb627

13 files changed

+659
-89
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ name: CodeQL
1515

1616
on:
1717
workflow_dispatch:
18-
schedule:
19-
- cron: '23 5 * * 0'
2018
pull_request:
2119
branches:
2220
- master

.github/workflows/lint.yaml

Lines changed: 0 additions & 20 deletions
This file was deleted.

.github/workflows/reuse.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
2+
# SPDX-License-Identifier: MIT
3+
4+
name: Test i386 (reusable)
5+
on:
6+
push:
7+
workflow_call:
8+
inputs:
9+
go-version:
10+
required: true
11+
type: string
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
test-i386:
18+
runs-on: ubuntu-22.04
19+
strategy:
20+
matrix:
21+
go-version: ['1.22', '1.23']
22+
name: Go i386 ${{ matrix.go-version }}
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Build worker
27+
run: |
28+
docker build -t test_runner_i386_${{matrix.go-version}}:latest -<<EOF
29+
FROM i386/golang:${{matrix.go-version}}-alpine
30+
RUN go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
31+
EOF
32+
33+
- name: Run test
34+
run: |
35+
if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi
36+
if [ -n "${SKIP_i386_TESTS}" ]; then exit 0; fi
37+
38+
mkdir -p $HOME/go/pkg/mod $HOME/.cache
39+
docker run \
40+
-u $(id -u):$(id -g) \
41+
-e "GO111MODULE=on" \
42+
-e "CGO_ENABLED=0" \
43+
-v $GITHUB_WORKSPACE:/go/src/github.com/pion/$(basename $GITHUB_WORKSPACE) \
44+
-v $HOME/go/pkg/mod:/go/pkg/mod \
45+
-v $HOME/.cache:/.cache \
46+
-w /go/src/github.com/pion/$(basename $GITHUB_WORKSPACE) \
47+
test_runner_i386_${{matrix.go-version}}:latest \
48+
/bin/sh -c "/usr/local/go/bin/go test ${TEST_EXTRA_ARGS:-} -json -v ./... | gotestfmt" ${TEST_EXTRA_ARGS:-} \
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
2+
# SPDX-License-Identifier: MIT
3+
4+
name: Test WASM (reusable)
5+
on:
6+
push:
7+
workflow_call:
8+
inputs:
9+
go-version:
10+
required: true
11+
type: string
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
test-wasm:
18+
runs-on: ubuntu-24.04
19+
name: WASM
20+
strategy:
21+
matrix:
22+
go-version: ['1.22', '1.23']
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Download Go
27+
run: |
28+
version=$(
29+
curl -s 'https://go.dev/dl/?mode=json&include=all' \
30+
| jq -r '.[].version | select(startswith("go${{ matrix.go-version }}."))' \
31+
| sort -V \
32+
| tail -n 1
33+
)
34+
curl -sSfL https://dl.google.com/go/${version}.linux-amd64.tar.gz | tar -C ~ -xzf -
35+
36+
- name: Node version
37+
id: node-version
38+
run: |
39+
if [ '${{ matrix.go-version }}' = '1.20' ]; then
40+
# Go 1.20's wasm_exec_node.js doesn't work with Node v20
41+
# This can be removed once all pion repositories are switched to use Go 1.22
42+
echo 'version=16' | tee -a ${GITHUB_OUTPUT}
43+
fi
44+
45+
- name: Use Node.js
46+
uses: actions/setup-node@v4
47+
with:
48+
node-version: '${{ steps.node-version.outputs.version || 20 }}.x'
49+
50+
- name: Set Go Root
51+
run: echo "GOROOT=${HOME}/go" >> $GITHUB_ENV
52+
53+
- name: Set Go Path
54+
run: echo "GOPATH=${HOME}/go" >> $GITHUB_ENV
55+
56+
- name: Set Go Path
57+
run: echo "GO_JS_WASM_EXEC=${GOROOT}/misc/wasm/go_js_wasm_exec" >> $GITHUB_ENV
58+
59+
- name: Install NPM modules
60+
run: yarn install
61+
62+
- name: Run Tests
63+
run: |
64+
if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi
65+
GOOS=js GOARCH=wasm \
66+
${GOPATH}/bin/go test \
67+
-exec="${GO_JS_WASM_EXEC}" \
68+
-v ./...

.github/workflows/test.reusable.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
2+
# SPDX-License-Identifier: MIT
3+
4+
name: Test
5+
on:
6+
push:
7+
workflow_call:
8+
inputs:
9+
go-version:
10+
required: true
11+
type: string
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
test:
18+
runs-on: ubuntu-24.04
19+
strategy:
20+
matrix:
21+
go-version: ['1.22', '1.23']
22+
name: Go ${{ matrix.go-version }}
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Setup Go
29+
uses: actions/setup-go@v5
30+
with:
31+
go-version: ${{ matrix.go-version }}
32+
33+
- name: Setup go-acc
34+
run: go install github.com/ory/go-acc@latest
35+
36+
- name: Setup gotestfmt
37+
uses: haveyoudebuggedit/gotestfmt-action@v2
38+
39+
- name: Run pre test hook
40+
run: |
41+
if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi
42+
if [ -n "${PRE_TEST_HOOK}" ]; then ${PRE_TEST_HOOK}; fi
43+
44+
- name: Run test
45+
run: |
46+
TEST_BENCH_OPTION="-bench=."
47+
if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi
48+
49+
set -euo pipefail
50+
go-acc -o cover.out ./... -- \
51+
${TEST_BENCH_OPTION} \
52+
-json \
53+
-v -race 2>&1 | grep -v '^go: downloading' | tee /tmp/gotest.log | gotestfmt
54+
55+
- name: Run post test hook
56+
run: |
57+
if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi
58+
if [ -n "${POST_TEST_HOOK}" ]; then ${POST_TEST_HOOK}; fi

.github/workflows/test.yaml

Lines changed: 0 additions & 45 deletions
This file was deleted.

0001-v.0.1.37-sp1.patch

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
From fa5b35ea867389cec33a9c82fffbd459ca8958e5 Mon Sep 17 00:00:00 2001
2+
From: Joe Turki <[email protected]>
3+
Date: Mon, 9 Jun 2025 07:39:14 +0300
4+
Subject: [PATCH] Fix padding overflow with PacketFactory
5+
6+
RTP padding overflow is now handled, instead of catching a panic.
7+
https://github.com/pion/webrtc/issues/3148
8+
---
9+
internal/rtpbuffer/errors.go | 1 +
10+
internal/rtpbuffer/packet_factory.go | 7 +++-
11+
internal/rtpbuffer/rtpbuffer_test.go | 48 ++++++++++++++++++++++++++++
12+
3 files changed, 55 insertions(+), 1 deletion(-)
13+
14+
diff --git a/internal/rtpbuffer/errors.go b/internal/rtpbuffer/errors.go
15+
index 57fca021..4c3112ba 100644
16+
--- a/internal/rtpbuffer/errors.go
17+
+++ b/internal/rtpbuffer/errors.go
18+
@@ -12,4 +12,5 @@ var (
19+
errPacketReleased = errors.New("could not retain packet, already released")
20+
errFailedToCastHeaderPool = errors.New("could not access header pool, failed cast")
21+
errFailedToCastPayloadPool = errors.New("could not access payload pool, failed cast")
22+
+ errPaddingOverflow = errors.New("padding size exceeds payload size")
23+
)
24+
diff --git a/internal/rtpbuffer/packet_factory.go b/internal/rtpbuffer/packet_factory.go
25+
index 3836acc3..c0e3468a 100644
26+
--- a/internal/rtpbuffer/packet_factory.go
27+
+++ b/internal/rtpbuffer/packet_factory.go
28+
@@ -84,7 +84,7 @@ func (m *PacketFactoryCopy) NewPacket(
29+
}
30+
}
31+
32+
- if rtxSsrc != 0 && rtxPayloadType != 0 {
33+
+ if rtxSsrc != 0 && rtxPayloadType != 0 { //nolint:nestif
34+
if payload == nil {
35+
retainablePacket.buffer, ok = m.payloadPool.Get().(*[]byte)
36+
if !ok {
37+
@@ -105,6 +105,11 @@ func (m *PacketFactoryCopy) NewPacket(
38+
if retainablePacket.header.Padding && retainablePacket.payload != nil && len(retainablePacket.payload) > 0 {
39+
paddingLength := int(retainablePacket.payload[len(retainablePacket.payload)-1])
40+
retainablePacket.header.Padding = false
41+
+
42+
+ if paddingLength > len(retainablePacket.payload) {
43+
+ return nil, errPaddingOverflow
44+
+ }
45+
+
46+
retainablePacket.payload = (*retainablePacket.buffer)[:len(retainablePacket.payload)-paddingLength]
47+
}
48+
}
49+
diff --git a/internal/rtpbuffer/rtpbuffer_test.go b/internal/rtpbuffer/rtpbuffer_test.go
50+
index 18cc265f..18b83ced 100644
51+
--- a/internal/rtpbuffer/rtpbuffer_test.go
52+
+++ b/internal/rtpbuffer/rtpbuffer_test.go
53+
@@ -4,6 +4,7 @@
54+
package rtpbuffer
55+
56+
import (
57+
+ "bytes"
58+
"testing"
59+
60+
"github.com/pion/rtp"
61+
@@ -218,3 +219,50 @@ func TestRTPBuffer_Overridden_WithRTX_NILPayload(t *testing.T) {
62+
63+
require.Nil(t, sb.Get(1))
64+
}
65+
+
66+
+func TestRTPBuffer_Padding(t *testing.T) {
67+
+ pm := NewPacketFactoryCopy()
68+
+ sb, err := NewRTPBuffer(1)
69+
+ require.NoError(t, err)
70+
+ require.Equal(t, uint16(1), sb.size)
71+
+
72+
+ t.Run("valid padding is stripped", func(t *testing.T) {
73+
+ origPayload := []byte{116, 101, 115, 116}
74+
+ expected := []byte{0, 1, 116, 101, 115, 116}
75+
+
76+
+ padLen := 120
77+
+ padded := make([]byte, 0)
78+
+ padded = append(padded, origPayload...)
79+
+ padded = append(padded, bytes.Repeat([]byte{0}, padLen-1)...)
80+
+ padded = append(padded, byte(padLen))
81+
+
82+
+ pkt, err := pm.NewPacket(&rtp.Header{
83+
+ SequenceNumber: 1,
84+
+ Padding: true,
85+
+ }, padded, 1, 1)
86+
+ require.NoError(t, err)
87+
+
88+
+ sb.Add(pkt)
89+
+
90+
+ retrieved := sb.Get(1)
91+
+ require.NotNil(t, retrieved)
92+
+ defer retrieved.Release()
93+
+
94+
+ require.False(t, retrieved.Header().Padding, "P-bit should be cleared after trimming")
95+
+
96+
+ actual := retrieved.Payload()
97+
+ require.Equal(t, len(expected), len(actual), "payload length after trimming")
98+
+ require.Equal(t, expected, actual, "payload content after trimming")
99+
+ })
100+
+
101+
+ t.Run("overflow padding returns io.ErrShortBuffer", func(t *testing.T) {
102+
+ overflow := []byte{0, 1, 200}
103+
+
104+
+ _, err := pm.NewPacket(&rtp.Header{
105+
+ SequenceNumber: 2,
106+
+ Padding: true,
107+
+ }, overflow, 1, 1)
108+
+
109+
+ require.ErrorIs(t, err, errPaddingOverflow, "factory should reject invalid padding")
110+
+ })
111+
+}

0 commit comments

Comments
 (0)