aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages
diff options
context:
space:
mode:
authorLeo Famulari <leo@famulari.name>2018-07-12 11:23:24 -0400
committerLeo Famulari <leo@famulari.name>2018-07-12 14:17:07 -0400
commitfd115bee31d04f1277560b82bb982e6aa19fc977 (patch)
tree420d95742837f44f9edb9d9967b58141633810fa /gnu/packages
parente81c952a4da21c7772f8104f4fcc44af3f403daf (diff)
downloadguix-fd115bee31d04f1277560b82bb982e6aa19fc977.tar
guix-fd115bee31d04f1277560b82bb982e6aa19fc977.tar.gz
gnu: Syncthing: Fix a crash bug.
* gnu/packages/patches/syncthing-fix-crash.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/syncthing.scm (syncthing)[source]: Use it.
Diffstat (limited to 'gnu/packages')
-rw-r--r--gnu/packages/patches/syncthing-fix-crash.patch72
-rw-r--r--gnu/packages/syncthing.scm2
2 files changed, 74 insertions, 0 deletions
diff --git a/gnu/packages/patches/syncthing-fix-crash.patch b/gnu/packages/patches/syncthing-fix-crash.patch
new file mode 100644
index 0000000000..d27e543982
--- /dev/null
+++ b/gnu/packages/patches/syncthing-fix-crash.patch
@@ -0,0 +1,72 @@
+Avoid a crash:
+
+https://github.com/syncthing/syncthing/issues/5002
+
+Patch copied from upstream source repository:
+
+https://github.com/syncthing/syncthing/commit/35a75a95dc6383b2d73ab645f1407f7907ec1a2c
+
+From 35a75a95dc6383b2d73ab645f1407f7907ec1a2c Mon Sep 17 00:00:00 2001
+From: Jakob Borg <jakob@kastelo.net>
+Date: Wed, 13 Jun 2018 19:07:52 +0200
+Subject: [PATCH] lib/model: Don't panic when rechecking file (fixes #5002)
+ (#5003)
+
+---
+ lib/model/model.go | 2 +-
+ lib/model/model_test.go | 26 ++++++++++++++++++++++++++
+ 2 files changed, 27 insertions(+), 1 deletion(-)
+
+diff --git a/lib/model/model.go b/lib/model/model.go
+index 5a9146e0..302f06c5 100644
+--- a/lib/model/model.go
++++ b/lib/model/model.go
+@@ -1373,7 +1373,7 @@ func (m *Model) recheckFile(deviceID protocol.DeviceID, folderFs fs.Filesystem,
+ return
+ }
+
+- if blockIndex > len(cf.Blocks) {
++ if blockIndex >= len(cf.Blocks) {
+ l.Debugf("%v recheckFile: %s: %q / %q i=%d: block index too far", m, deviceID, folder, name, blockIndex)
+ return
+ }
+diff --git a/lib/model/model_test.go b/lib/model/model_test.go
+index 295eafc1..456bbc4a 100644
+--- a/lib/model/model_test.go
++++ b/lib/model/model_test.go
+@@ -3608,6 +3608,32 @@ func TestIssue4903(t *testing.T) {
+ }
+ }
+
++func TestIssue5002(t *testing.T) {
++ // recheckFile should not panic when given an index equal to the number of blocks
++
++ db := db.OpenMemory()
++ m := NewModel(defaultCfgWrapper, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
++ m.AddFolder(defaultFolderConfig)
++ m.StartFolder("default")
++
++ m.ServeBackground()
++ defer m.Stop()
++
++ if err := m.ScanFolder("default"); err != nil {
++ t.Error(err)
++ }
++
++ file, ok := m.CurrentFolderFile("default", "foo")
++ if !ok {
++ t.Fatal("test file should exist")
++ }
++ nBlocks := len(file.Blocks)
++
++ m.recheckFile(protocol.LocalDeviceID, defaultFolderConfig.Filesystem(), "default", "foo", nBlocks-1, []byte{1, 2, 3, 4})
++ m.recheckFile(protocol.LocalDeviceID, defaultFolderConfig.Filesystem(), "default", "foo", nBlocks, []byte{1, 2, 3, 4}) // panic
++ m.recheckFile(protocol.LocalDeviceID, defaultFolderConfig.Filesystem(), "default", "foo", nBlocks+1, []byte{1, 2, 3, 4})
++}
++
+ func addFakeConn(m *Model, dev protocol.DeviceID) *fakeConnection {
+ fc := &fakeConnection{id: dev, model: m}
+ m.AddConnection(fc, protocol.HelloResult{})
+--
+2.18.0
+
diff --git a/gnu/packages/syncthing.scm b/gnu/packages/syncthing.scm
index 14e83b5861..4c0bceedf6 100644
--- a/gnu/packages/syncthing.scm
+++ b/gnu/packages/syncthing.scm
@@ -24,6 +24,7 @@
#:use-module (guix download)
#:use-module (guix git-download)
#:use-module (guix licenses)
+ #:use-module (gnu packages)
#:use-module (gnu packages golang))
(define-public syncthing
@@ -35,6 +36,7 @@
(uri (string-append "https://github.com/syncthing/syncthing"
"/releases/download/v" version
"/syncthing-source-v" version ".tar.gz"))
+ (patches (search-patches "syncthing-fix-crash.patch"))
(sha256
(base32
"0bxkm5jlj6l4gai23bg0y31brr80r9qllh1rdg29pahjn0c2b4ml"))