mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-10-18 04:47:28 +00:00
Size computation for allocation may overflow (#99)
* Size computation for allocation may overflow Performing calculations involving the size of potentially large strings or slices can result in an overflow (for signed integer types) or a wraparound (for unsigned types). An overflow causes the result of the calculation to become negative, while a wraparound results in a small (positive) number.
This commit is contained in:
@@ -169,7 +169,10 @@ func (jwk *JWK) ToRSAPublicKey() (*rsa.PublicKey, error) {
|
||||
// Pad to 8 bytes for uint64
|
||||
paddedE := make([]byte, 8)
|
||||
copy(paddedE[8-len(eBytes):], eBytes)
|
||||
e = int(binary.BigEndian.Uint64(paddedE))
|
||||
eUint64 := binary.BigEndian.Uint64(paddedE)
|
||||
// RSA exponents are typically small (65537 is common), so overflow is not a concern
|
||||
// #nosec G115 -- RSA public exponents are small values that fit in int
|
||||
e = int(eUint64)
|
||||
} else {
|
||||
return nil, fmt.Errorf("exponent too large")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user