Skip to content

Commit f2c6663

Browse files
authored
Fix nil deref in LiveOS path, size bound, and AzL2 scope (#715)
https://github.com/microsoft/azure-linux-image-tools/actions/runs/25187282741 <!-- Description: Please provide a summary of the changes and the motivation behind them. --> --- ### **Checklist** - [ ] Tests added/updated - [ ] Documentation updated (if needed) - [ ] Code conforms to style guidelines
1 parent cab6959 commit f2c6663

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

toolkit/tools/pkg/imagecustomizerlib/customizeverity_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,13 @@ func verifyUsrInlineVerity(t *testing.T, baseImageInfo testBaseImageInfo, buildD
10721072
}
10731073

10741074
func TestCustomizeImageVerityRootInlineCosi(t *testing.T) {
1075-
for _, baseImageInfo := range baseImageAzureLinuxAll {
1075+
// This test uses a UKI config that requires systemd-boot, which is only
1076+
// available on AzureLinux 3 for now.
1077+
azl3Images := []testBaseImageInfo{
1078+
testBaseImageAzl3CoreEfi,
1079+
testBaseImageAzl3BareMetal,
1080+
}
1081+
for _, baseImageInfo := range azl3Images {
10761082
t.Run(baseImageInfo.Name, func(t *testing.T) {
10771083
testCustomizeImageVerityRootInlineCosiHelper(t, "TestCustomizeImageVerityRootInlineCosi"+baseImageInfo.Name, baseImageInfo)
10781084
})
@@ -1192,7 +1198,7 @@ func testCustomizeImageVerityRootInlineCosiHelper(t *testing.T, testName string,
11921198
// implementation details, and randomness. So, just enforce that the final size is below an arbitary value. Values
11931199
// were picked by observing values seen during test and adding a good buffer.
11941200
assert.Greater(t, int64(100*diskutils.MiB), bootStat.Size())
1195-
assert.Greater(t, int64(500*diskutils.MiB), rootStat.Size())
1201+
assert.Greater(t, int64(600*diskutils.MiB), rootStat.Size())
11961202
assert.Greater(t, int64(150*diskutils.MiB), varStat.Size())
11971203

11981204
espDevice, err := safeloopback.NewLoopback(espPartitionPath)

toolkit/tools/pkg/imagecustomizerlib/liveosisoimages.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,13 @@ func createWriteableImageFromArtifacts(buildDir string, inputArtifactsStore *Iso
545545
},
546546
}
547547

548+
// Validate and populate computed partition fields (e.g. End, Size) that are
549+
// required by downstream code such as diskConfigToImager.
550+
err = diskConfig.IsValid()
551+
if err != nil {
552+
return fmt.Errorf("failed to validate disk config for writeable image:\n%w", err)
553+
}
554+
548555
fileSystemConfigs := []imagecustomizerapi.FileSystem{
549556
{
550557
DeviceId: "rootfs",

0 commit comments

Comments
 (0)