Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
grep: avoid shell code evaluation (#749)
* grep: avoid shell code evaluation * When running grep -g or -u, the default code uses Term::Cap but this fails over to executing external tput command * tput would be available on Linux/BSD but is not a consideration for Windows * Feed the TERM environment variable to tput command in single quotes to prevent shell commands from being initiated though TERM * To verify this I had to temporarily bypass the Term::Cap code on my Linux system * No other instances of backticks, system() or exec() calls within grep %TERM='linux;halt -p;' perl grep -g include a.c # with patch applied tput fails but system doesn't halt tput: unknown terminal "linux;halt -p;" tput: unknown terminal "linux;halt -p;" #include <stdio.h> #include <stdlib.h> * execute tput without subshell * Previous commit was half baked because invalid user input could still creep into shell * Switch backticks over to system LIST, which does not execute tput via a shell * Code for redirecting and restoring STDOUT was lifted out of bin/awk
- Loading branch information