Skip to content

Commit e195177

Browse files
Merge pull request #24578 from Luap99/addHosts-nil-deref
libpod: addHosts() prevent nil deref
2 parents a132e62 + d513973 commit e195177

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

libpod/container_internal_common.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2322,7 +2322,7 @@ func (c *Container) addHosts() error {
23222322
// not be routed to the host.
23232323
// https://github.com/containers/podman/issues/22653
23242324
info, err := c.runtime.network.RootlessNetnsInfo()
2325-
if err == nil {
2325+
if err == nil && info != nil {
23262326
exclude = info.IPAddresses
23272327
if len(info.MapGuestIps) > 0 {
23282328
// we used --map-guest-addr to setup pasta so prefer this address

libpod/container_internal_linux.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ func (c *Container) addSpecialDNS(nameservers []string) []string {
624624
switch {
625625
case c.config.NetMode.IsBridge():
626626
info, err := c.runtime.network.RootlessNetnsInfo()
627-
if err == nil {
627+
if err == nil && info != nil {
628628
nameservers = append(nameservers, info.DnsForwardIps...)
629629
}
630630
case c.pastaResult != nil:

0 commit comments

Comments
 (0)