Skip to content

Commit

Permalink
caddyauth: Use buffered channel passed to signal.Notify (#3895)
Browse files Browse the repository at this point in the history
The docs at os/signal.Notify warn about this signal delivery loss bug at
https://golang.org/pkg/os/signal/#Notify, which says:

    Package signal will not block sending to c: the caller must ensure
    that c has sufficient buffer space to keep up with the expected signal
    rate. For a channel used for notification of just one signal value,
    a buffer of size 1 is sufficient.

Caught by a static analysis tool from Orijtech, Inc. called "sigchanyzer"
  • Loading branch information
cuonglm authored Dec 1, 2020
1 parent a26f70a commit 4cff36d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/caddyhttp/caddyauth/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func cmdHashPassword(fs caddycmd.Flags) (int, error) {
if terminal.IsTerminal(fd) {
// ensure the terminal state is restored on SIGINT
state, _ := terminal.GetState(fd)
c := make(chan os.Signal)
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
go func() {
<-c
Expand Down

0 comments on commit 4cff36d

Please sign in to comment.