Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions ext/formatting.go
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,8 @@ func parseFormattingClause(formatStr string, callback formatStringInterpolator)
}
}

const maxPrecision = 1000
Comment thread
Flo354 marked this conversation as resolved.
Outdated

func parsePrecision(formatStr string) (int, *int, error) {
i := 0
if formatStr[i] != '.' {
Expand All @@ -891,6 +893,9 @@ func parsePrecision(formatStr string) (int, *int, error) {
if err != nil {
return -1, nil, fmt.Errorf("error while converting precision to integer: %w", err)
}
if precision > maxPrecision {
return -1, nil, fmt.Errorf("precision %d exceeds maximum allowed precision %d", precision, maxPrecision)
}
return i, &precision, nil
}

Expand Down
3 changes: 3 additions & 0 deletions ext/formatting_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -784,5 +784,8 @@ func parsePrecisionV2(formatStr string) (int, int, error) {
if precision < 0 {
return -1, -1, fmt.Errorf("negative precision: %d", precision)
}
if precision > maxPrecision {
return -1, -1, fmt.Errorf("precision %d exceeds maximum allowed precision %d", precision, maxPrecision)
}
return i, precision, nil
}