Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut...
by formerly_proven on Tuesday April 19, 2022 @03:17AM
(#31080423)
It always seemed very strange to me that there is no way to generate escaped representations in sh/bash, because you do need that from time to time.
[ Parent
| on HN ]
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut...
by phh on Tuesday April 19, 2022 @03:41AM
(#31080544)
There is printf %q, a bashism I think
Sample usage to escape var called v v="$(printf '%q' "$v")"
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut...
by unqueued on Tuesday April 19, 2022 @10:22AM
(#31083533)
This is called ANSI-C quoting[1], and I am surprised it is not more popular, because I think it provides a good compromise with readability and power.
I used it myself when I wrote a script that generates a self executing bash script to restore mtimes for directories[2]
[1]: https://www.gnu.org/software/bash/manual/bash.html#ANSI_002d...
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut...
by formerly_proven on Tuesday April 19, 2022 @08:06AM
(#31082013)
Thanks!