diff --git a/cmd/sojuctl/main.go b/cmd/sojuctl/main.go index 368d2d8..d7bcdeb 100644 --- a/cmd/sojuctl/main.go +++ b/cmd/sojuctl/main.go @@ -120,7 +120,12 @@ func readPassword() ([]byte, error) { } else { fmt.Fprintf(os.Stderr, "Warning: Reading password from stdin.\n") scanner := bufio.NewScanner(os.Stdin) - scanner.Scan() + if !scanner.Scan() { + if err := scanner.Err(); err != nil { + log.Fatalf("failed to read password from stdin: %v", err) + } + log.Fatalf("failed to read password from stdin: stdin is empty") + } password = scanner.Bytes() if len(password) == 0 {