File descriptor leak on error path in Run (command/connect/envoy/pipe-bootstrap/connect_envoy_pipe-bootstrap.go)
- Dominant language
- Go
- Stars
- 30.1k
- Forks
- 4.6k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 39
Description
Description:
In command/connect/envoy/pipe-bootstrap/connect_envoy_pipe-bootstrap.go, function Run, a file descriptor opened via:
f, err := os.OpenFile(args[0], os.O_WRONLY|os.O_APPEND, 0700)
can be leaked on an error path.
If buf.WriteTo(f) fails, the function returns:
return 1
before calling f.Close().
The success path correctly calls f.Close() (around line 70), but on the error path the descriptor remains open.
This results in a file descriptor leak when buf.WriteTo returns an error.
Expected behavior:
The file descriptor should be closed on all return paths.
A minimal fix would be:
f.Close()
return 1
or alternatively register defer f.Close() immediately after the successful os.OpenFile.
Happy to submit a minimal PR if helpful.
Contributor guide
Research direction
Read command/connect/envoy/pipe-bootstrap/connect_envoy_pipe-bootstrap.go and start at Run, following the os.OpenFile and buf.WriteTo error path. Done means the opened file descriptor is closed on every return path, including when buf.WriteTo fails.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100