mirror of
https://github.com/containers/podman.git
synced 2025-11-29 09:37:38 +08:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user