Skip to content

Commit 5161388

Browse files
committed
Handle NULL bytes when reading ignition from bootfifo
1 parent 79a4713 commit 5161388

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

internal/providers/nvidiabluefield/nvidiabluefield.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package nvidia_bluefield
1616

1717
import (
18+
"bytes"
1819
"os"
1920

2021
"github.com/coreos/ignition/v2/config/v3_6_experimental/types"
@@ -37,7 +38,7 @@ func init() {
3738
}
3839

3940
func fetchConfig(f *resource.Fetcher) (cfg types.Config, rpt report.Report, err error) {
40-
data, err := os.ReadFile(bootfifoPath)
41+
raw, err := os.ReadFile(bootfifoPath)
4142
if os.IsNotExist(err) {
4243
f.Logger.Info("NVIDIA BlueField bootfifo was not found. Ignoring...")
4344
cfg, rpt, err = util.ParseConfig(f.Logger, []byte{})
@@ -47,12 +48,14 @@ func fetchConfig(f *resource.Fetcher) (cfg types.Config, rpt report.Report, err
4748
return
4849
}
4950

50-
if len(data) == 0 {
51+
if len(raw) == 0 {
5152
f.Logger.Info("no config found in NVIDIA BlueField bootfifo")
5253
cfg, rpt, err = util.ParseConfig(f.Logger, []byte{})
5354
return
5455
}
5556

57+
data := bytes.Trim(raw, "\x00")
58+
5659
cfg, rpt, err = util.ParseConfig(f.Logger, data)
5760
return
5861
}

0 commit comments

Comments
 (0)