Fix CodeQL warnings

This commit is contained in:
Ben Johnson
2022-01-30 10:17:36 -07:00
parent 0dfa5f98d1
commit f6c859061b
6 changed files with 54 additions and 23 deletions

8
db.go
View File

@@ -12,6 +12,7 @@ import (
"io"
"io/ioutil"
"log"
"math"
"math/rand"
"os"
"path/filepath"
@@ -1593,8 +1594,11 @@ func parseWALPath(s string) (index int, err error) {
return 0, fmt.Errorf("invalid wal path: %s", s)
}
i64, _ := strconv.ParseUint(a[1], 16, 64)
return int(i64), nil
i32, _ := strconv.ParseUint(a[1], 16, 32)
if i32 > math.MaxInt32 {
return 0, fmt.Errorf("index too large in wal path: %s", s)
}
return int(i32), nil
}
// formatWALPath formats a WAL filename with a given index.