Add UTF-8-support to strings(1), add t-flag and refactor code

Previously, the string-length was limited to BUFSIZ, which is an
obvious deficiency.
Now the buffer only needs to be as long as the user specifies the
minimal string length.
I added UTF-8-support, because that's how POSIX wants it and there
are cases where you need this. It doesn't add ELF-barf compared to
the previous implementation.
The t-flag is also pretty important for POSIX-compliance, so I added
it.
The only trouble previously was the a-flag, but given that POSIX
leaves undefined what the a-flag actually does, we set it as default
and don't care about parsing ELF-headers, which has already
turned out to be a security issue in GNU coreutils[0].

[0]: http://lcamtuf.blogspot.ro/2014/10/psa-dont-run-strings-on-untrusted-files.html
This commit is contained in:
FRIGN
2015-02-17 17:04:36 +01:00
parent 949dafc171
commit e5b5497773
3 changed files with 80 additions and 35 deletions

2
README
View File

@@ -67,7 +67,7 @@ The following tools are implemented ('*' == finished, '#' == UTF-8 support,
sort no -m, -o, -d, -f, -i
=* split yes none
=* sponge non-posix none
strings no -t
#* strings yes none
=* sync non-posix none
=* tail yes none
=* tar non-posix none