quadlet: fix runtime error for invalid Mount value

If the `Mount` option inside a quadlet is missing the source=... part,
the code today panics with the following message.

```
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/containers/podman/v5/pkg/systemd/quadlet.handleStorageSource(0xc000140de0?, 0x1d?, {0x0?, 0x1?}, 0x5634e39e233e?, 0x10?)
...
```

This commit checks for the missing source and returns an error to avoid the panic.

Signed-off-by: Jakob Meier <mail@jakobmeier.ch>
This commit is contained in:
Jakob Meier
2025-09-03 23:11:23 +02:00
parent c24b8f6f56
commit 163bdf2df8
3 changed files with 11 additions and 0 deletions

View File

@@ -1858,6 +1858,9 @@ func handleLogOpt(unitFile *parser.UnitFile, groupName string, podman *PodmanCmd
}
func handleStorageSource(quadletUnitFile, serviceUnitFile *parser.UnitFile, source string, unitsInfoMap map[string]*UnitInfo, checkImage bool) (string, error) {
if source == "" {
return "", fmt.Errorf("source cannot be empty")
}
if source[0] == '.' {
var err error
source, err = getAbsolutePath(quadletUnitFile, source)