mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-01 17:52:40 +00:00
runtime: Fix Incorrect conversion between integer types
Fix the high severity codeql issue by checking the value is in bounds before converting Signed-off-by: stevenhorsman <steven@uk.ibm.com>
This commit is contained in:
parent
4de79b9821
commit
5472662b33
@ -11,6 +11,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -1776,9 +1777,18 @@ func (k *kataAgent) handleDeviceBlockVolume(c *Container, m Mount, device api.De
|
|||||||
if len(vol.Options) == 0 {
|
if len(vol.Options) == 0 {
|
||||||
vol.Options = m.Options
|
vol.Options = m.Options
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.FSGroup != nil {
|
if m.FSGroup != nil {
|
||||||
|
var safeFsgroup uint32
|
||||||
|
// Check conversions from int to uint32 is safe
|
||||||
|
if *m.FSGroup > 0 && *m.FSGroup <= math.MaxUint32 {
|
||||||
|
safeFsgroup = uint32(*m.FSGroup)
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("m.FSGroup value was out of range: %d", m.FSGroup)
|
||||||
|
|
||||||
|
}
|
||||||
vol.FsGroup = &grpc.FSGroup{
|
vol.FsGroup = &grpc.FSGroup{
|
||||||
GroupId: uint32(*m.FSGroup),
|
GroupId: safeFsgroup,
|
||||||
GroupChangePolicy: getFSGroupChangePolicy(m.FSGroupChangePolicy),
|
GroupChangePolicy: getFSGroupChangePolicy(m.FSGroupChangePolicy),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user