]> git.feebdaed.xyz Git - 0xmirror/runc.git/commitdiff
libct: startInitialization: add defer close
authorKir Kolyshkin <kolyshkin@gmail.com>
Wed, 12 Nov 2025 21:13:48 +0000 (13:13 -0800)
committerKir Kolyshkin <kolyshkin@gmail.com>
Tue, 2 Dec 2025 23:15:23 +0000 (15:15 -0800)
This function calls Init what normally never returns, so the defer only
works if there is an error and we can safely use it to close those fds
we opened. This was done for most but not all fds.

Reported in issue 5008.

Reported-by: Arina Cherednik <arinacherednik034@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
libcontainer/init_linux.go

index 31166170eb62941948914e41d6570842c015ef60..99b99debae6897d8b5592cdc669a9f6a13caa228 100644 (file)
@@ -175,6 +175,7 @@ func startInitialization() (retErr error) {
                return fmt.Errorf("unable to convert _LIBCONTAINER_LOGPIPE: %w", err)
        }
        logPipe := os.NewFile(uintptr(logFd), "logpipe")
+       defer logPipe.Close()
 
        logrus.SetOutput(logPipe)
        logrus.SetFormatter(new(logrus.JSONFormatter))
@@ -190,6 +191,7 @@ func startInitialization() (retErr error) {
                        return fmt.Errorf("unable to convert _LIBCONTAINER_FIFOFD: %w", err)
                }
                fifoFile = os.NewFile(uintptr(fifoFd), "initfifo")
+               defer fifoFile.Close()
        }
 
        var consoleSocket *os.File