@@ -21,10 +21,11 @@ import (
2121 "strconv"
2222 "strings"
2323
24- "github.com/livekit/ingress/pkg/errors"
2524 "github.com/livekit/protocol/logger"
2625 "github.com/livekit/protocol/pprof"
2726 "github.com/livekit/psrpc"
27+
28+ "github.com/livekit/ingress/pkg/errors"
2829)
2930
3031const (
@@ -80,14 +81,22 @@ func (s *Service) handlePProf(w http.ResponseWriter, r *http.Request) {
8081 var err error
8182 var b []byte
8283
83- timeout , _ := strconv .Atoi (r .URL .Query ().Get ("timeout" ))
84- debug , _ := strconv .Atoi (r .URL .Query ().Get ("debug" ))
84+ timeout , err := strconv .ParseInt (r .URL .Query ().Get ("timeout" ), 10 , 32 )
85+ if err != nil {
86+ http .Error (w , "malformed timeout" , http .StatusBadRequest )
87+ return
88+ }
89+ debug , err := strconv .ParseInt (r .URL .Query ().Get ("debug" ), 10 , 32 )
90+ if err != nil {
91+ http .Error (w , "malformed debug" , http .StatusBadRequest )
92+ return
93+ }
8594
8695 pathElements := strings .Split (r .URL .Path , "/" )
8796 switch len (pathElements ) {
8897 case 3 :
8998 // profile main service
90- b , err = pprof .GetProfileData (context .Background (), pathElements [2 ], timeout , debug )
99+ b , err = pprof .GetProfileData (context .Background (), pathElements [2 ], int ( timeout ), int ( debug ) )
91100
92101 case 4 :
93102 resourceID := pathElements [2 ]
@@ -97,7 +106,7 @@ func (s *Service) handlePProf(w http.ResponseWriter, r *http.Request) {
97106 return
98107 }
99108
100- b , err = api .GetProfileData (context .Background (), pathElements [3 ], timeout , debug )
109+ b , err = api .GetProfileData (context .Background (), pathElements [3 ], int32 ( timeout ), int32 ( debug ) )
101110 if err != nil {
102111 return
103112 }
0 commit comments