Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/ingester/pyroscope/ingest_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (h ingestHandler) parseInputMetadataFromRequest(_ context.Context, r *http.
}

if sr := q.Get("sampleRate"); sr != "" {
sampleRate, err := strconv.Atoi(sr)
sampleRate, err := strconv.ParseUint(sr, 10, 32)
if err != nil {
_ = h.log.Log(
"err", err,
Expand Down
4 changes: 4 additions & 0 deletions pkg/metastore/fsm/log_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ func marshal(v proto.Message) ([]byte, error) {
if err != nil {
return raw, err
}
maxRawSize := 64 * 1024 * 1024 // 64 MB guard
if len(raw) > maxRawSize {
return nil, fmt.Errorf("marshaled message too large: %d bytes", len(raw))
}
buf := make([]byte, 4+len(raw))
copy(buf[4:], raw)
return buf, err
Expand Down
4 changes: 4 additions & 0 deletions pkg/og/util/bytesize/bytesize.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package bytesize
import (
"errors"
"fmt"
"math"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -88,6 +89,9 @@ func Parse(str string) (ByteSize, error) {
if err != nil {
return 0, errParse
}
if val > uint64(math.MaxInt64) {
return 0, errParse
}
return ByteSize(val) * multiplier, nil
}

Expand Down
10 changes: 10 additions & 0 deletions pkg/querier/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"context"
"encoding/json"
"fmt"
"sort"

Check failure on line 7 in pkg/querier/replication.go

View workflow job for this annotation

GitHub Actions / lint

File is not properly formatted (gofmt)
"math"

"github.com/cespare/xxhash/v2"
"github.com/go-kit/log"
Expand Down Expand Up @@ -249,6 +250,15 @@
// not a sharded block continue
continue
}

// Bounds check before converting shards and using as slice length or index
if shards == 0 || shards > uint64(math.MaxInt) {
return false, fmt.Errorf("invalid shard count (must be 1..%d), got: %d, for block id %s", math.MaxInt, shards, block)
}
if shardIdx >= shards {
return false, fmt.Errorf("invalid shardIdx: %d for shard count %d", shardIdx, shards)
}

hasShardedBlocks = true
shardedBlocks = append(shardedBlocks, block)

Expand Down
7 changes: 5 additions & 2 deletions pkg/storegateway/gateway_blocks_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
import (
_ "embed" // Used to embed html template
"fmt"
"html/template"

Check failure on line 8 in pkg/storegateway/gateway_blocks_http.go

View workflow job for this annotation

GitHub Actions / lint

File is not properly formatted (gofmt)
"net/http"
"path/filepath"
"strconv"
"time"
"math"

"github.com/dustin/go-humanize"
"github.com/gorilla/mux"
Expand Down Expand Up @@ -74,9 +75,11 @@
showParents := req.Form.Get("show_parents") == "on"
var splitCount int
if sc := req.Form.Get("split_count"); sc != "" {
splitCount, _ = strconv.Atoi(sc)
if splitCount < 0 {
parsed, _ := strconv.ParseInt(sc, 10, 32)
if parsed < 0 || parsed > int64(math.MaxUint32) {
splitCount = 0
} else {
splitCount = int(parsed)
}
}

Expand Down
Loading