Skip to content

Commit

Permalink
fix: suppress gosec overflow issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ethernal committed Sep 13, 2024
1 parent 2f28035 commit 1197155
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ func (a *Aggregator) handleReceivedDataStream(
oldDBBatch.Batch.AccInputHash,
a.currentStreamBatch.BatchL2Data,
a.currentStreamBatch.L1InfoRoot,
uint64(a.currentStreamBatch.Timestamp.Unix()),
uint64(a.currentStreamBatch.Timestamp.Unix()), //nolint:gosec
a.currentStreamBatch.Coinbase,
forcedBlockhashL1,
)
Expand Down
2 changes: 1 addition & 1 deletion aggregator/prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ func GetStateRootFromProof(proof string) (common.Hash, error) {
if err != nil {
log.Fatal(err)
}
v[j] = uint64(u64)
v[j] = uint64(u64) //nolint:gosec
j++
}
bigSR := fea2scalar(v[:])
Expand Down
2 changes: 1 addition & 1 deletion merkletree/split.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func h4ToScalar(h4 []uint64) *big.Int {

for i := 1; i < 4; i++ {
b2 := new(big.Int).SetUint64(h4[i])
b2.Lsh(b2, uint(wordLength*i))
b2.Lsh(b2, uint(wordLength*i)) //nolint:gosec
result = result.Add(result, b2)
}

Expand Down
2 changes: 1 addition & 1 deletion sequencesender/sequencesender.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ func (s *SequenceSender) tryToSendSequence(ctx context.Context) {
// Sanity check: Wait also until current time is L1BlockTimestampMargin seconds above the
// timestamp of the last L2 block in the sequence
for {
currentTime := uint64(time.Now().Unix())
currentTime := uint64(time.Now().Unix()) //nolint:gosec

elapsed, waitTime := s.marginTimeElapsed(lastL2BlockTimestamp, currentTime, timeMargin)

Expand Down
6 changes: 3 additions & 3 deletions state/encoding_batch_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,13 @@ func DecodeTxRLP(txsData []byte, offset int) (int, *L2TxRaw, error) {
if err != nil {
return 0, nil, fmt.Errorf("can't get RLP length (offset=%d): %w", offset, err)
}
endPos := uint64(offset) + length + rLength + sLength + vLength + EfficiencyPercentageByteLength
endPos := uint64(offset) + length + rLength + sLength + vLength + EfficiencyPercentageByteLength //nolint:gosec
if endPos > uint64(len(txsData)) {
return 0, nil, fmt.Errorf("can't get tx because not enough data (endPos=%d lenData=%d): %w",
endPos, len(txsData), ErrInvalidBatchV2)
}
fullDataTx := txsData[offset:endPos]
dataStart := uint64(offset) + length
dataStart := uint64(offset) + length //nolint:gosec
txInfo := txsData[offset:dataStart]
rData := txsData[dataStart : dataStart+rLength]
sData := txsData[dataStart+rLength : dataStart+rLength+sLength]
Expand Down Expand Up @@ -360,7 +360,7 @@ func decodeRLPListLengthFromOffset(txsData []byte, offset int) (uint64, error) {
length := num - c0
if length > shortRlp { // If rlp is bigger than length 55
// n is the length of the rlp data without the header (1 byte) for example "0xf7"
pos64 := uint64(offset)
pos64 := uint64(offset) //nolint:gosec
lengthInByteOfSize := num - f7
if (pos64 + headerByteLength + lengthInByteOfSize) > txDataLength {
log.Debug("error not enough data: ")
Expand Down

0 comments on commit 1197155

Please sign in to comment.