Skip to content

Commit 77373a8

Browse files
authored
fix(shelley): check rat lower bounds (#1221)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent bf47329 commit 77373a8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

ledger/shelley/pparams.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,17 +171,23 @@ func (u *ShelleyProtocolParameterUpdate) UnmarshalCBOR(cborData []byte) error {
171171

172172
func (p *ShelleyProtocolParameters) Utxorpc() (*cardano.PParams, error) {
173173
// sanity check
174-
if p.A0.Num().Int64() > math.MaxInt32 ||
174+
if p.A0 == nil ||
175+
p.A0.Num().Int64() < math.MinInt32 ||
176+
p.A0.Num().Int64() > math.MaxInt32 ||
175177
p.A0.Denom().Int64() < 0 ||
176178
p.A0.Denom().Int64() > math.MaxUint32 {
177179
return nil, errors.New("invalid A0 rational number values")
178180
}
179-
if p.Rho.Num().Int64() > math.MaxInt32 ||
181+
if p.Rho == nil ||
182+
p.Rho.Num().Int64() < math.MinInt32 ||
183+
p.Rho.Num().Int64() > math.MaxInt32 ||
180184
p.Rho.Denom().Int64() < 0 ||
181185
p.Rho.Denom().Int64() > math.MaxUint32 {
182186
return nil, errors.New("invalid Rho rational number values")
183187
}
184-
if p.Tau.Num().Int64() > math.MaxInt32 ||
188+
if p.Tau == nil ||
189+
p.Tau.Num().Int64() < math.MinInt32 ||
190+
p.Tau.Num().Int64() > math.MaxInt32 ||
185191
p.Tau.Denom().Int64() < 0 ||
186192
p.Tau.Denom().Int64() > math.MaxUint32 {
187193
return nil, errors.New("invalid Tau rational number values")

0 commit comments

Comments
 (0)