Skip to content

Commit 8f28a7b

Browse files
committed
fpga: fix integer type conversion error reported by CodeQL
to address: "Incorrect conversion of an unsigned 32-bit integer from to a lower bit size type int without an upper bound check." Signed-off-by: Mikko Ylinen <[email protected]>
1 parent 64cdec8 commit 8f28a7b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pkg/fpga/dfl_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ func (f *DflFME) GetPortsNum() int {
236236
}
237237

238238
n, err := strconv.ParseUint(f.PortsNum, 10, 32)
239-
if err != nil {
239+
if err != nil || n >= math.MaxInt {
240240
return -1
241241
}
242242

pkg/fpga/intel_fpga_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ func (f *IntelFpgaFME) GetPortsNum() int {
241241
}
242242

243243
n, err := strconv.ParseUint(f.PortsNum, 10, 32)
244-
if err != nil {
244+
if err != nil || n >= math.MaxInt {
245245
return -1
246246
}
247247

0 commit comments

Comments
 (0)