1
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-11-04 08:17:24 -05:00

Fix missing error check of bufio.Scanner (#29882)

maybe more
This commit is contained in:
coldWater 2024-03-19 10:20:36 +08:00 committed by GitHub
parent 1f0d31ce8f
commit 0e183d81fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 30 additions and 0 deletions

View File

@ -152,6 +152,10 @@ func RegeneratePublicKeys(ctx context.Context, t io.StringWriter) error {
return err return err
} }
} }
err = scanner.Err()
if err != nil {
return fmt.Errorf("scan: %w", err)
}
f.Close() f.Close()
} }
return nil return nil

View File

@ -9,6 +9,7 @@ import (
"bytes" "bytes"
"context" "context"
"errors" "errors"
"fmt"
"io" "io"
"os/exec" "os/exec"
"strconv" "strconv"
@ -396,6 +397,10 @@ func (c *Commit) GetSubModules() (*ObjectCache, error) {
} }
} }
} }
err = scanner.Err()
if err != nil {
return nil, fmt.Errorf("scan: %w", err)
}
return c.submoduleCache, nil return c.submoduleCache, nil
} }

View File

@ -124,6 +124,10 @@ func (repo *Repository) GetCodeActivityStats(fromTime time.Time, branch string)
} }
} }
} }
err = scanner.Err()
if err != nil {
return fmt.Errorf("scan: %w", err)
}
a := make([]*CodeActivityAuthor, 0, len(authors)) a := make([]*CodeActivityAuthor, 0, len(authors))
for _, v := range authors { for _, v := range authors {
a = append(a, v) a = append(a, v)

View File

@ -6,6 +6,7 @@ package markup
import ( import (
"bufio" "bufio"
"bytes" "bytes"
"fmt"
"html" "html"
"io" "io"
"regexp" "regexp"
@ -123,6 +124,10 @@ func (Renderer) fallbackRender(input io.Reader, tmpBlock *bufio.Writer) error {
return err return err
} }
} }
err = scan.Err()
if err != nil {
return fmt.Errorf("scan: %w", err)
}
_, err = tmpBlock.WriteString("</pre>") _, err = tmpBlock.WriteString("</pre>")
if err != nil { if err != nil {

View File

@ -980,5 +980,9 @@ func getExcerptLines(commit *git.Commit, filePath string, idxLeft, idxRight, chu
} }
diffLines = append(diffLines, diffLine) diffLines = append(diffLines, diffLine)
} }
err = scanner.Err()
if err != nil {
return nil, fmt.Errorf("scan: %w", err)
}
return diffLines, nil return diffLines, nil
} }

View File

@ -122,6 +122,10 @@ func regeneratePrincipalKeys(ctx context.Context, t io.StringWriter) error {
return err return err
} }
} }
err = scanner.Err()
if err != nil {
return fmt.Errorf("scan: %w", err)
}
f.Close() f.Close()
} }
return nil return nil

View File

@ -51,6 +51,10 @@ func checkAuthorizedKeys(ctx context.Context, logger log.Logger, autofix bool) e
} }
linesInAuthorizedKeys.Add(line) linesInAuthorizedKeys.Add(line)
} }
err = scanner.Err()
if err != nil {
return fmt.Errorf("scan: %w", err)
}
f.Close() f.Close()
// now we regenerate and check if there are any lines missing // now we regenerate and check if there are any lines missing