Skip to content

Commit 84dccd1

Browse files
committed
update generate video for proper escaping
1 parent 9218653 commit 84dccd1

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

web/includes/Event.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -865,18 +865,19 @@ public function GenerateVideo($rate=0, $fps=0, $scale=0, $size=0, $overwrite=fal
865865
$command = ZM_PATH_FFMPEG
866866
." -y -r $frame_rate "
867867
.ZM_FFMPEG_INPUT_OPTIONS
868-
.' -i ' . $event_path.'/'.( $this->DefaultVideo() ? $this->DefaultVideo() : '%0'.ZM_EVENT_IMAGE_DIGITS .'d-capture.jpg' )
868+
." -i ".escapeshellarg($event_path.'/'.( $this->DefaultVideo() ? $this->DefaultVideo() : '%0'.ZM_EVENT_IMAGE_DIGITS .'d-capture.jpg' ))
869869
#. " -f concat -i /tmp/event_files.txt"
870870
#
871-
.implode(' ', array_map(function($t){ return ' -vf '.$t; }, explode(',', $transforms)))
871+
.implode(' ', array_map(function($t){ return ' -vf '.escapeshellarg($t); }, array_filter(explode(',', $transforms), 'strlen')))
872872
." -s $video_size "
873873

874874
.ZM_FFMPEG_OUTPUT_OPTIONS
875-
." '$event_path/$video_file' > $event_path/ffmpeg.log 2>&1"
875+
." ".escapeshellarg($event_path.'/'.$video_file)." > ".escapeshellarg($event_path.'/ffmpeg.log')." 2>&1"
876876
;
877877
Debug($command);
878-
if(!exec(escapeshellcmd($command), $output, $rc)) {
879-
Error("Unable to generate video, check $event_path/ffmpeg.log for details");
878+
exec($command, $output, $rc);
879+
if($rc !== 0) {
880+
Error("Unable to generate video, check $event_path/ffmpeg.log for details. Output: " . implode("\n", $output) . " (rc=$rc)");
880881
return;
881882
}
882883

0 commit comments

Comments
 (0)