Searched hist:226948 (Results 1 - 1 of 1) sorted by relevance

/freebsd-11-stable/usr.bin/apply/
H A Dapply.cdiff 337825 Wed Aug 15 01:33:21 MDT 2018 kevans MFC r337504: apply(1): Fix magic number substitution with a magic space

Using a space as the magic character would result in problems if the command
started with a number:

- For a 'valid' number n, n < size of argv, it would erroneously get
replaced with that argument; e.g. `apply -a ' ' -d 1rm x => `execxrm x`

- For an 'invalid' number n, n >= size of argv, it would segfault.
e.g. `apply -a ' ' 2to3 test.py` would try to access argv[2]

This problem occurred because apply(1) would prepend "exec " to the command
string before doing the actual magic number replacements, so it would come
across "exec 2to3 1" and assume that the " 2" is also a magic number to be
replaced.

Re-work this to instead just append "exec " to the command sbuf and
workaround the ugliness. This also simplifies stuff in the process.

PR: 226948

Completed in 100 milliseconds