Bug #5761
segfault when pre-process/post-process/post-remove command contain special characters
Status:
Fixed
Priority:
Normal
Assignee:
-
Category:
Crashes
Target version:
-
Start date:
2019-10-31
Due date:
% Done:
0%
Estimated time:
Found in version:
4.3-1845~g02cae0f3d
Affected Versions:
Description
Summary¶
I observed unexpected behavior using the properties (under Configuration / Recording / Digital Video Recorder Profiles / Miscellaneous Settings):- pre-processor command
- post-processor-command
- post-remove command
Certain commands cause error messages in the log or even reproduceable segfaults.
Observed behavior¶
sh -c '/bin/df -P -h /recordings >/config/.markers/recording-pre-process'
causes[ ERROR] spawn: shift: usage: shift [ -n arg# ] [ -b block# ] prog...
sh -c "/bin/df -P -h /recordings >/config/.markers/recording-pre-process"
causestvheadend[4243]: segfault at 7ffe162bb000 ip 00007f5919eb54e1 sp 00007ffe162b7518 error 4 in ld-musl-x86_64.so.1[7f5919e7b000+46000]
bash -c '/bin/df -P -h /recordings >/config/.markers/recording-pre-process'
causes[ ERROR] spawn: -P: -c: line 0: unexpected EOF while looking for matching `''
[ ERROR] spawn: -P: -c: line 1: syntax error: unexpected end of file
bash -c "/bin/df -P -h /recordings | tee /config/.markers/recording-pre-process"
causessegfault at fffffffffffffffe ip 000055db1f3d884b sp 00007fffcda939a0 error 7 in tvheadend[55db1f384000+158000]
Analysis¶
I found in dvr_rec.c and hts_str.c that the command is parsed and splitted. The processing of double quotes and spaces seems to cause the problems. I guess that single quotes (') and redirections (e.g. | < >) are not supported at all, not even wrapped in a shell string.
Expected behavior¶
No segfault, and one of:- Support of arbitrary shell commands
- Documentation about the limitations (preferably as mouse-over description in the configuration)
Workaround¶
Create a shell script that contains the command with quoted arguments and redirections.
History
Updated by Jaroslav Kysela about 5 years ago
- Status changed from New to Fixed
Crash fixed in v4.3-1849-g0afdc9d3a..
If you like to improve the help, modify docs/property/postprocessor.md and create the pull request on github. Thanks.
The correct syntax:
sh -c "/bin/df -P -h /recordings >/config/.markers/recording-pre-process"
It will execute sh with arguments -c and /bin/df -P -h /recordings >/config/.markers/recording-pre-process .