Skip to content

Commit 240b46f

Browse files
committed
Switch to gofrs/uuid
github.com/satori/go.uuid is unmaintained and contains several critical flaws.
1 parent 80ebe4f commit 240b46f

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module github.com/foxcpp/filedrop
22

33
require (
4+
github.com/gofrs/uuid/v3 v3.1.1
45
github.com/mattn/go-sqlite3 v1.9.0
56
github.com/pkg/errors v0.8.0
6-
github.com/satori/go.uuid v1.2.0
77
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
github.com/gofrs/uuid/v3 v3.1.1 h1:sqMK0jjyOJ7HV36lwG2GZ6TD2hK8RB7dJQVDakI65U4=
2+
github.com/gofrs/uuid/v3 v3.1.1/go.mod h1:xPwMqoocQ1L5G6pXX5BcE7N5jlzn2o19oqAKxwZW/kI=
13
github.com/mattn/go-sqlite3 v1.9.0 h1:pDRiWfl+++eC2FEFRy6jXmQlvp4Yh3z1MJKg4UeYM/4=
24
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
35
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
46
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
5-
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
6-
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=

server.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
"strings"
1313
"time"
1414

15+
"github.com/gofrs/uuid/v3"
1516
"github.com/pkg/errors"
16-
"github.com/satori/go.uuid"
1717
)
1818

1919
var ErrFileDoesntExists = errors.New("file doesn't exists")
@@ -44,10 +44,13 @@ func New(conf Config) (*Server, error) {
4444
// AddFile adds file to storage and returns assigned UUID which can be directly
4545
// substituted into URL.
4646
func (s *Server) AddFile(contents io.Reader, contentType string, maxUses uint, storeUntil time.Time) (string, error) {
47-
fileUUID := uuid.NewV4()
47+
fileUUID, err := uuid.NewV4()
48+
if err != nil {
49+
return "", errors.Wrap(err, "UUID generation")
50+
}
4851
outLocation := filepath.Join(s.Conf.StorageDir, fileUUID.String())
4952

50-
_, err := os.Stat(outLocation)
53+
_, err = os.Stat(outLocation)
5154
if err == nil {
5255
return "", errors.New("UUID collision detected")
5356
}

0 commit comments

Comments
 (0)