Skip to content

Commit 575e856

Browse files
authored
Merge pull request #1673 from tomaioo/fix/security/out-of-bounds-read-in-base64-decoder-can
fix(security): 2 improvements across 2 files
2 parents 08586c1 + 011d38d commit 575e856

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

base/iox/imagex/base64.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func Base64SplitLines(b []byte) []byte {
4747

4848
// FromBase64 returns image from Base64-encoded bytes
4949
func FromBase64(eb []byte) (image.Image, Formats, error) {
50-
if eb[76] == ' ' {
50+
if len(eb) > 76 && eb[76] == ' ' {
5151
eb = bytes.ReplaceAll(eb, []byte(" "), []byte("\n"))
5252
}
5353
db := make([]byte, base64.StdEncoding.DecodedLen(len(eb)))

cmd/changed.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
func Changed(c *config.Config) error { //types:add
2424
wg := sync.WaitGroup{}
2525
errs := []error{}
26+
errMu := sync.Mutex{}
2627
fs.WalkDir(os.DirFS("."), ".", func(path string, d fs.DirEntry, err error) error {
2728
wg.Add(1)
2829
go func() {
@@ -33,7 +34,9 @@ func Changed(c *config.Config) error { //types:add
3334
dir := filepath.Dir(path)
3435
out, err := exec.Major().SetDir(dir).Output("git", "diff")
3536
if err != nil {
37+
errMu.Lock()
3638
errs = append(errs, fmt.Errorf("error getting diff of %q: %w", dir, err))
39+
errMu.Unlock()
3740
return
3841
}
3942
if out != "" { // if we have a diff, we have been changed
@@ -43,7 +46,9 @@ func Changed(c *config.Config) error { //types:add
4346
// if we don't have a diff, we also check to make sure we aren't ahead of the remote
4447
out, err = exec.Minor().SetDir(dir).Output("git", "status")
4548
if err != nil {
49+
errMu.Lock()
4650
errs = append(errs, fmt.Errorf("error getting status of %q: %w", dir, err))
51+
errMu.Unlock()
4752
return
4853
}
4954
if strings.Contains(out, "Your branch is ahead") { // if we are ahead, we have been changed

0 commit comments

Comments
 (0)