4 ms·
The commit fixing this bug is here: https://git.savannah.gnu.org/cgit/gzip.git/commit/?id=dc9740df61e575e8c3148b7bd3c147a81ea00c7c https://git.savannah.gnu.org/
by TheDong 5y ago
The commit fixing this bug is here: https://git.savannah.gnu.org/cgit/gzip.git/commit/?id=dc9740df61e575e8c3148b7bd3c147a81ea00c7c https://git.savannah.gnu.org/cgit/gzip.git/commit/?id=dc9740...
while grep is written in C, zgrep is written in posix sh, and the bug was from using sed to escape arguments, and sed being a line-oriented utility that is non-ideal for operating on newline-containing strings (i.e. linux filenames).
- nikonyrh 5y agoThis reminds me that filenames can contain newlines.
- tomrod 5y agoD:
- guipsp 5y agoAnd nulls :)
- hddqsb 5y agoHow exactly can they contain nulls? fopen() takes a null-terminated filename, so if there is a null byte in the middle it would just truncate the filename.
- minusf 5y agothat might be a corrupt filename that can be opened only by its inode in debugfs or similar.
- teddyh 5y agoNo they can’t.
- 10000truths 5y agoThey can contain any octet except ASCII NUL and /. That said, pretty much every filesystem's on-disk format has an explicit length field for file names. So in theory, there's nothing stopping them from supporting completely binary filenames - it's the kernel's VFS layer that treats NUL and / as special.
- foota 5y agoThe thought of writing anything in sh is horrifying to me.
- djbusby 5y agoCheck out GNU pass It's like all sh
- 0xdeadb00f 5y agoI didn't know pass was "GNU". I also recall it being pretty well written.
- guns 5y agoOriginal author of password-store was Jason Donenfeld (of Wireguard fame), and it was indeed well-written.
- 0xdeadb00f 5y agoYes! Actually I remember now being surprised to find out Jason had written it. His git repository is full of neat and interesting projects.
- loudmax 5y agoPass is a wrapper script around git and gpg. You can get the functionality of `pass` by running git and gpg commands directly. Learning git itself is non-intuitive, but the gpg utilities take the learning curve to a whole other level. If you want to make simple use of the gpg utilities, you should plan on setting aside a few full days to learn how they work. Or just use pass, which additionally leverages git for password history.
- scbrg 5y agobash, actually.
- bee_rider 5y agoWell, this seems like the sort of error that we've all made when throwing together our own personal scripts, so I guess it is somewhat heartening that the serious Redhat folks would make it too.
- formerly_proven 5y agoIt 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.
- phh 5y agoThere is printf %q, a bashism I think Sample usage to escape var called v v="$(printf '%q' "$v")"
- formerly_proven 5y agoThanks!
- unqueued 5y agoThis 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_002dC-Quoting https://www.gnu.org/software/bash/manual/bash.html#ANSI_002d... [2]: https://github.com/unqueued/storetouch https://github.com/unqueued/storetouch