Skip to content

Commit

Permalink
added filepath.Clean for better secuirty
Browse files Browse the repository at this point in the history
  • Loading branch information
ngmisl committed Jun 11, 2024
1 parent 9013fa4 commit 9797aec
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module example.com/jpe

go 1.22.2
go 1.22.4

require github.com/gen2brain/jpegli v0.2.2

Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
github.com/gen2brain/jpegli v0.1.2 h1:2BFpt6sdze/ROP/zGiKWOiKaNZCxqDcS7I0/oNksJog=
github.com/gen2brain/jpegli v0.1.2/go.mod h1:ArNook7A3NfU+ibQ5gko0DgQKilME4Q0sEt9rcSPaN8=
github.com/gen2brain/jpegli v0.2.0 h1:v12qDA6zydwvp4AxtwlC791OT11tMAExKiaTT7BhFlU=
github.com/gen2brain/jpegli v0.2.0/go.mod h1:ArNook7A3NfU+ibQ5gko0DgQKilME4Q0sEt9rcSPaN8=
github.com/gen2brain/jpegli v0.2.2 h1:GrhioJ/ZqrI+N4gKMBs+sggCipBEU141MJwQKJYAmbo=
github.com/gen2brain/jpegli v0.2.2/go.mod h1:ArNook7A3NfU+ibQ5gko0DgQKilME4Q0sEt9rcSPaN8=
github.com/tetratelabs/wazero v1.7.0 h1:jg5qPydno59wqjpGrHph81lbtHzTrWzwwtD4cD88+hQ=
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func main() {

for _, arg := range os.Args[1:] {
// Read the input PNG image from a file
inputImageBytes, err := os.ReadFile(arg)
inputImageBytes, err := os.ReadFile(filepath.Clean(arg))
if err != nil {
log.Printf("Error reading PNG file %s: %v", arg, err)
continue
Expand Down Expand Up @@ -87,7 +87,7 @@ func main() {
outputFilename := filepath.Base(arg[:len(arg)-len(filepath.Ext(arg))]) + ".jpeg"
outputPath := filepath.Join(outputDir, outputFilename)

if err := os.WriteFile(outputPath, jpegliBytes, 0644); err != nil {
if err := os.WriteFile(filepath.Clean(outputPath), jpegliBytes, 0644); err != nil {
log.Printf("Error saving Jpegli file %s: %v", outputPath, err)
continue
}
Expand Down

0 comments on commit 9797aec

Please sign in to comment.