Message:
Hello [email protected] (cc: [email protected]),
I'd like you to review this change to
https://go.googlecode.com/hg/
Description:
crypto/rand: better panic message for invalid Int argument.
Also document the panic to be consistent with math/rand.
Fixes issue 5187.
Please review this at https://codereview.appspot.com/8303043/
Affected files:
M src/pkg/crypto/rand/util.go
Index: src/pkg/crypto/rand/util.go
===================================================================
--- a/src/pkg/crypto/rand/util.go
+++ b/src/pkg/crypto/rand/util.go
@@ -100,8 +100,11 @@
}
}
-// Int returns a uniform random value in [0, max).
+// Int returns a uniform random value in [0, max). It panics if max <= 0.
func Int(rand io.Reader, max *big.Int) (n *big.Int, err error) {
+ if max.Sign() <= 0 {
+ panic("crypto/rand: argument to Int is <= 0")
+ }
k := (max.BitLen() + 7) / 8
// b is the number of bits in the most significant byte of max.
--
---
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.