Skip to content

Commit

Permalink
[#270] Audit issue C: Properly check read()
Browse files Browse the repository at this point in the history
  • Loading branch information
HonzaR authored Apr 14, 2024
1 parent 26094e2 commit fb9233c
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ actual class SecureRandom {
bytes.usePinned {
read(randomData, it.addressOf(0), bytes.size.convert())
}
check(result >= 0) {
// Warning: Operator '==' cannot be applied to 'ssize_t /* = Long */' and 'Int'
// Converting both sides to Long to ensure they fit in the range
check(result.toLong() == bytes.size.toLong()) {
"Could not get random number from /dev/urandom"
}
}
Expand Down

0 comments on commit fb9233c

Please sign in to comment.