Skip to content

bug: file descriptor leak on z/OS s390x when FcntlInt fails #2255

Description

@pageton

Description

tcplisten/socket_zos_s390x.go:11-18 leaks the socket file descriptor when FcntlInt fails:

fd, err := unix.Socket(domain, typ, proto)  // succeeds
_, err = unix.FcntlInt(...)                  // overwrites err
_, err = unix.FcntlInt(...)                  // fails
if err == nil {
    return fd, nil
}
return -1, fmt.Errorf(...)  // fd leaked, never closed

Impact

  • File descriptor leak on z/OS s390x when FcntlInt fails
  • Accumulates over process lifetime on affected platform

Suggested Fix

Close fd before returning the error:

if err != nil {
    unix.Close(fd)
    return -1, fmt.Errorf(...)
}

File

tcplisten/socket_zos_s390x.go:11-18

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions