mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
[1.4] libct: newProcessComm: close fds on error
Reported in issue 5008.
Reported-by: Arina Cherednik <arinacherednik034@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit c24965b742)
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
committed by
Aleksa Sarai
parent
ffc6092b8d
commit
0af85cbca8
@@ -70,7 +70,7 @@ type processComm struct {
|
||||
logPipeChild *os.File
|
||||
}
|
||||
|
||||
func newProcessComm() (*processComm, error) {
|
||||
func newProcessComm() (_ *processComm, retErr error) {
|
||||
var (
|
||||
comm processComm
|
||||
err error
|
||||
@@ -79,10 +79,24 @@ func newProcessComm() (*processComm, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to create init pipe: %w", err)
|
||||
}
|
||||
defer func() {
|
||||
if retErr != nil {
|
||||
comm.initSockParent.Close()
|
||||
comm.initSockChild.Close()
|
||||
}
|
||||
}()
|
||||
|
||||
comm.syncSockParent, comm.syncSockChild, err = newSyncSockpair("sync")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to create sync pipe: %w", err)
|
||||
}
|
||||
defer func() {
|
||||
if retErr != nil {
|
||||
comm.syncSockParent.Close()
|
||||
comm.syncSockChild.Close()
|
||||
}
|
||||
}()
|
||||
|
||||
comm.logPipeParent, comm.logPipeChild, err = os.Pipe()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to create log pipe: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user