Skip to content

Commit

Permalink
webrtc: fix crash when reading from path 'publish' (#2688) (#2692)
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Nov 13, 2023
1 parent e8f5715 commit a760a98
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/core/webrtc_http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func (s *webRTCHTTPServer) onRequest(ctx *gin.Context) {

case len(ctx.Request.URL.Path) >= 2:
switch {
case strings.HasSuffix(ctx.Request.URL.Path, "/publish"):
case len(ctx.Request.URL.Path) > len("/publish") && strings.HasSuffix(ctx.Request.URL.Path, "/publish"):
s.onPage(ctx, ctx.Request.URL.Path[1:len(ctx.Request.URL.Path)-len("/publish")], true)

case ctx.Request.URL.Path[len(ctx.Request.URL.Path)-1] != '/':
Expand Down
4 changes: 2 additions & 2 deletions internal/core/webrtc_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import (

func TestWebRTCPages(t *testing.T) {
p, ok := newInstance("paths:\n" +
" stream:\n")
" all:\n")
require.Equal(t, true, ok)
defer p.Close()

hc := &http.Client{Transport: &http.Transport{}}

for _, path := range []string{"/stream", "/stream/publish"} {
for _, path := range []string{"/stream", "/stream/publish", "/publish"} {
func() {
req, err := http.NewRequest(http.MethodGet, "http://localhost:8889"+path, nil)
require.NoError(t, err)
Expand Down

0 comments on commit a760a98

Please sign in to comment.