mirror of
https://github.com/PrivateCaptcha/PrivateCaptcha.git
synced 2026-02-11 00:08:47 -06:00
Fix CodeQL suggestion
This commit is contained in:
@@ -4,11 +4,12 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"log/slog"
|
||||
"math"
|
||||
"net/http"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
"time"
|
||||
"math"
|
||||
|
||||
"golang.org/x/net/xsrftoken"
|
||||
)
|
||||
|
||||
@@ -17,9 +18,6 @@ const (
|
||||
maxHeaderLen = 100
|
||||
)
|
||||
|
||||
// Error returned when a path arg integer is out of int32 bounds
|
||||
var errPathArgOutOfBounds = errors.New("path arg integer out of int32 bounds")
|
||||
|
||||
var (
|
||||
headerHtmxRequest = http.CanonicalHeaderKey("HX-Request")
|
||||
errPathArgEmpty = errors.New("path argument is empty")
|
||||
@@ -144,10 +142,7 @@ func IntPathArg(r *http.Request, name string, hasher IdentifierHasher) (int32, s
|
||||
|
||||
if hasher != nil {
|
||||
i, err := hasher.Decrypt(value)
|
||||
if err == nil {
|
||||
if i < 0 || i > math.MaxInt32 {
|
||||
return 0, value, errPathArgOutOfBounds
|
||||
}
|
||||
if (err == nil) && (i >= 0) && (i < math.MaxInt32) {
|
||||
return int32(i), value, nil
|
||||
}
|
||||
slog.ErrorContext(r.Context(), "Failed to decrypt hashed int param", "value", value, ErrAttr(err))
|
||||
|
||||
Reference in New Issue
Block a user