Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade v0.45.5 #131

Merged
merged 18 commits into from
Jul 18, 2022
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
6811eca
fix: decrement types.Dec max length to keep decimal bits in DecimalPr…
mergify[bot] Apr 27, 2022
330ab41
fix: Bug reading password from a buffer when reader returns EOF (back…
mergify[bot] Apr 27, 2022
cede16b
refactor: improve error messages (backport #11762) (#11887)
mergify[bot] May 6, 2022
5d3a86c
feat: add feegrant query to see allowances from a given granter (back…
julienrbrt May 6, 2022
59a103f
fix: grants by granter pagination `total` (#11813) (#11828)
mergify[bot] May 12, 2022
14d749b
refactor: remove redacted message (backport #11960) (#12002)
mergify[bot] May 20, 2022
43729fa
fix: index ante events for failed tx (backport: #12013) (#12017)
yihuang May 23, 2022
629e64c
fix: Make rechecking a tx check the sequence number #12060 (#12062)
mergify[bot] May 27, 2022
b0fd587
fix: cli `grants-by-grantee`, `grants-by-granter` cmds (backport #119…
mergify[bot] May 27, 2022
4d7ced5
fix: add base account getter (backport #12154) (#12161)
mergify[bot] Jun 6, 2022
babc593
refactor: Simplify SimulationManager setup (backport #12153) (#12159)
mergify[bot] Jun 7, 2022
8316c75
perf: modify DelegatorSharesInvariant for better performance (#12170)…
mergify[bot] Jun 7, 2022
2e9e76c
chore: remove direct reliance on staking from slashing (backport #121…
mergify[bot] Jun 7, 2022
708855e
fix(upgrades): perform no-op if 'from' and 'to' migration version are…
mergify[bot] Jun 8, 2022
212e825
chore(types): add MustAccAddressFromBech32 util func (backport #12201…
mergify[bot] Jun 9, 2022
689a716
Revert "fix: add base account getter (backport #12154) (#12161)" (#12…
alexanderbez Jun 9, 2022
933589f
chore: prep release notes + cl (#12207)
alexanderbez Jun 9, 2022
311bd57
fix: install tparse workflow
daeMOn63 Jul 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: Bug reading password from a buffer when reader returns EOF (back…
…port #11796) (#11810)
  • Loading branch information
mergify[bot] authored and daeMOn63 committed Jun 17, 2022
commit 330ab419c98ec432f928f54db69835aac67eecd5
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

* [#11796](https://github.com/cosmos/cosmos-sdk/pull/11796) Handle EOF error case in `readLineFromBuf`, which allows successful reading of passphrases from STDIN.
* [\#11772](https://github.com/cosmos/cosmos-sdk/pull/11772) Limit types.Dec length to avoid overflow.

## [v0.45.4](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.45.4) - 2022-04-25
18 changes: 16 additions & 2 deletions client/input/input.go
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ package input

import (
"bufio"
"errors"
"fmt"
"io"
"os"
@@ -83,12 +84,25 @@ func inputIsTty() bool {
return isatty.IsTerminal(os.Stdin.Fd()) || isatty.IsCygwinTerminal(os.Stdin.Fd())
}

// readLineFromBuf reads one line from stdin.
// readLineFromBuf reads one line from reader.
// Subsequent calls reuse the same buffer, so we don't lose
// any input when reading a password twice (to verify)
func readLineFromBuf(buf *bufio.Reader) (string, error) {
pass, err := buf.ReadString('\n')
if err != nil {

switch {
case errors.Is(err, io.EOF):
// If by any chance the error is EOF, but we were actually able to read
// something from the reader then don't return the EOF error.
// If we didn't read anything from the reader and got the EOF error, then
// it's safe to return EOF back to the caller.
if len(pass) > 0 {
// exit the switch statement
break
}
return "", err

case err != nil:
return "", err
}

57 changes: 57 additions & 0 deletions client/input/input_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package input

import (
"bufio"
"errors"
"io"
"testing"

"github.com/stretchr/testify/require"
)

type fakeReader struct {
fnc func(p []byte) (int, error)
}

func (f fakeReader) Read(p []byte) (int, error) {
return f.fnc(p)
}

var _ io.Reader = fakeReader{}

func TestReadLineFromBuf(t *testing.T) {
var fr fakeReader

t.Run("it correctly returns the password when reader returns EOF", func(t *testing.T) {
fr.fnc = func(p []byte) (int, error) {
return copy(p, []byte("hello")), io.EOF
}
buf := bufio.NewReader(fr)

pass, err := readLineFromBuf(buf)
require.NoError(t, err)
require.Equal(t, "hello", pass)
})

t.Run("it returns EOF if reader has been exhausted", func(t *testing.T) {
fr.fnc = func(p []byte) (int, error) {
return 0, io.EOF
}
buf := bufio.NewReader(fr)

_, err := readLineFromBuf(buf)
require.ErrorIs(t, err, io.EOF)
})

t.Run("it returns the error if it's not EOF regardles if it read something or not", func(t *testing.T) {
expectedErr := errors.New("oh no")
fr.fnc = func(p []byte) (int, error) {
return copy(p, []byte("hello")), expectedErr
}
buf := bufio.NewReader(fr)

_, err := readLineFromBuf(buf)
require.ErrorIs(t, err, expectedErr)
})

}