Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Nowhere in the spec (http://linux.die.net/man/3/strfry) it's written that the permutation is uniformly random, it just says

> The strfry() function randomizes the contents of string by using rand(3) to randomly swap characters in the string. The result is an anagram of string.

It doesn't even say that every permutation can be produced. So the code is already compliant to the spec.

The difference with the memcpy issue is that nobody is really using strfry, especially nobody expecting an uniform permutation (rand() has ridiculously little entropy, and the space of permutations is huge).

Still, put in context this bug report is very funny :)



What is meant by Random? Random distribution is always uniform unless otherwise mentioned. It means every event should be equally likely as well.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: