]> git.ipfire.org Git - thirdparty/coreutils.git/commit
shuf: improve randperm overflow checking
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 22 Oct 2019 19:58:07 +0000 (12:58 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 22 Oct 2019 22:04:43 +0000 (15:04 -0700)
commit74163ea677b6daf129b8bc03f8a9058a77ef3702
tree1777f8dcb9c4bc507a86f13476d4717223833a7f
parent565dd395c3ebbab4e8a4ceb47932814c693ed637
shuf: improve randperm overflow checking

* gl/lib/randperm.c: Include randperm.h first, since it’s the API.
Include stdint.h, count-leading-zeros.h, verify.h.
(floor_lg): Rename from ceil_log (which was not actually
implementing the ceiling!) and implement the floor using
count_leading_zeros.
(randperm_bound): Use floor_lg, not ceil_log.  Use uintmax_t
instead of size_t in case the size gets large on a 32-bit host.
* gl/modules/randperm (Depends-on): Add count-leading-zeros, stdint.
gl/lib/randperm.c
gl/modules/randperm