Skip to content

Commit

Permalink
Fixing two security issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
cinar committed Dec 3, 2023
1 parent 919a13c commit 4fb02b2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions helper/csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"io"
"log"
"os"
"path/filepath"
"reflect"
"sync"
)
Expand Down Expand Up @@ -142,7 +143,7 @@ func (c *Csv[T]) ReadFromReader(reader io.Reader) <-chan *T {
// maps the data to corresponding struct fields, and delivers
// the resulting snapshots through the channel.
func (c *Csv[T]) ReadFromFile(fileName string) (<-chan *T, error) {
file, err := os.Open(fileName)
file, err := os.Open(filepath.Clean(fileName))
if err != nil {
return nil, err
}
Expand All @@ -152,7 +153,10 @@ func (c *Csv[T]) ReadFromFile(fileName string) (<-chan *T, error) {

go func() {
wg.Wait()
file.Close()
err := file.Close()
if err != nil {
log.Printf("file close failed with %v", err)
}
}()

return rows, nil
Expand Down

0 comments on commit 4fb02b2

Please sign in to comment.