mirror of
https://github.com/trufflesecurity/trufflehog.git
synced 2024-11-10 07:04:24 +00:00
Fix binary file hanging bug in git sources (#2388)
Waiting for the sub-command will block until all of `stdout` has been read. In some cases, we return early due to failed chunking without reading all of the data, and thus, get stuck waiting for the command to finish. Closing the pipe will ensure `Wait` does not block on that I/O.
This commit is contained in:
parent
95616b01f9
commit
01c9ac7b59
2 changed files with 6 additions and 0 deletions
|
@ -375,6 +375,9 @@ func (c *Parser) executeCommand(ctx context.Context, cmd *exec.Cmd, isStaged boo
|
|||
|
||||
go func() {
|
||||
c.FromReader(ctx, stdOut, commitChan, isStaged)
|
||||
if err := stdOut.Close(); err != nil {
|
||||
ctx.Logger().V(2).Info("Error closing git stdout pipe.", "error", err)
|
||||
}
|
||||
if err := cmd.Wait(); err != nil {
|
||||
ctx.Logger().V(2).Info("Error waiting for git command to complete.", "error", err)
|
||||
}
|
||||
|
|
|
@ -1143,6 +1143,9 @@ func (s *Git) handleBinary(ctx context.Context, gitDir string, reporter sources.
|
|||
return err
|
||||
}
|
||||
defer func() {
|
||||
if err := fileReader.Close(); err != nil {
|
||||
ctx.Logger().Error(err, "error closing fileReader")
|
||||
}
|
||||
if err := cmd.Wait(); err != nil {
|
||||
ctx.Logger().Error(
|
||||
err, "error waiting for command",
|
||||
|
|
Loading…
Reference in a new issue