Fix command injection in api-server for HTTP callback. v5.0.157, v6.0.48 · ossrs/srs@1e43bb6 · GitHub
Skip to content

Commit 1e43bb6

Browse files
panda1986winlinvip
authored andcommitted
Fix command injection in api-server for HTTP callback. v5.0.157, v6.0.48
1 parent 1545425 commit 1e43bb6

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

trunk/doc/CHANGELOG.md

Lines changed: 1 addition & 0 deletions

trunk/research/api-server/server.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,18 @@ func (v *SnapshotJob) do(ffmpegPath, inputUrl string) (err error) {
400400
normalPicPath := path.Join(outputPicDir, fmt.Sprintf("%v", v.Stream)+"-%03d.png")
401401
bestPng := path.Join(outputPicDir, fmt.Sprintf("%v-best.png", v.Stream))
402402

403-
param := fmt.Sprintf("%v -i %v -vf fps=1 -vcodec png -f image2 -an -y -vframes %v -y %v", ffmpegPath, inputUrl, v.vframes, normalPicPath)
404-
log.Println(fmt.Sprintf("start snapshot, cmd param=%v", param))
403+
params := []string{
404+
"-i", inputUrl,
405+
"-vf", "fps=1",
406+
"-vcodec", "png",
407+
"-f", "image2",
408+
"-an",
409+
"-vframes", strconv.Itoa(v.vframes),
410+
"-y", normalPicPath,
411+
}
412+
log.Println(fmt.Sprintf("start snapshot, cmd param=%v %v", ffmpegPath, strings.Join(params, " ")))
405413
timeoutCtx, _ := context.WithTimeout(v.cancelCtx, v.timeout)
406-
cmd := exec.CommandContext(timeoutCtx, "/bin/bash", "-c", param)
414+
cmd := exec.CommandContext(timeoutCtx, ffmpegPath, params...)
407415
if err = cmd.Run(); err != nil {
408416
log.Println(fmt.Sprintf("run snapshot %v cmd failed, err is %v", v.Tag(), err))
409417
return

trunk/src/core/srs_core_version5.hpp

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)