]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
sort(1): Simplify and bound random seeding
authorcem <cem@FreeBSD.org>
Thu, 11 Apr 2019 05:08:49 +0000 (05:08 +0000)
committercem <cem@FreeBSD.org>
Thu, 11 Apr 2019 05:08:49 +0000 (05:08 +0000)
commit04b7883bc0d536a11bb3b90081090d09f0d6be8c
tree9f456a3d0aa040131a22a7e8a913814ea14cfadd
parent06483b03268106c5b8e1680716f0003b81e21cff
sort(1): Simplify and bound random seeding

Bound input file processing length to avoid the issue reported in [1].  For
simplicity, only allow regular file and character device inputs.  For
character devices, only allow /dev/random (and /dev/urandom symblink).

32 bytes of random is perfectly sufficient to seed MD5; we don't need any
more.  Users that want to use large files as seeds are encouraged to truncate
those files down to an appropriate input file via tools like sha256(1).

(This does not change the sort algorithm of sort -R.)

[1]: https://lists.freebsd.org/pipermail/freebsd-hackers/2018-August/053152.html

PR: 230792
Reported by: Ali Abdallah <aliovx AT gmail.com>
Relnotes: yes
usr.bin/sort/sort.c