Skip to content

Commit

Permalink
strcov atoi check
Browse files Browse the repository at this point in the history
  • Loading branch information
jonfung-dydx committed Oct 21, 2024
1 parent b829b28 commit 47cfb5b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions protocol/streaming/ws/websocket_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ws
import (
"context"
"fmt"
"math"
"net/http"
"strconv"
"strings"
Expand Down Expand Up @@ -122,6 +123,10 @@ func parseSubaccountIds(r *http.Request) ([]*satypes.SubaccountId, error) {
return nil, fmt.Errorf("invalid subaccount number: %s, expected subaccount_id format: owner/number", parts[1])
}

if number < 0 || number > math.MaxInt32 {
return nil, fmt.Errorf("invalid subaccount number: %s", parts[1])
}

subaccountIds = append(subaccountIds, &satypes.SubaccountId{
Owner: parts[0],
Number: uint32(number),
Expand All @@ -144,6 +149,9 @@ func parseClobPairIds(r *http.Request) ([]uint32, error) {
if err != nil {
return nil, fmt.Errorf("invalid clobPairId: %s", idStr)
}
if id < 0 || id > math.MaxInt32 {
return nil, fmt.Errorf("invalid clob pair id: %s", idStr)
}
clobPairIds = append(clobPairIds, uint32(id))
}

Expand Down

0 comments on commit 47cfb5b

Please sign in to comment.