]> Cypherpunks repositories - nncp.git/commitdiff
Validate the last chunk's size too
authorSergey Matveev <stargrave@stargrave.org>
Fri, 28 Apr 2017 13:12:52 +0000 (16:12 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Fri, 28 Apr 2017 13:12:57 +0000 (16:12 +0300)
src/cypherpunks.ru/nncp/cmd/nncp-reass/main.go

index 588ba0e6956ffaa33c2a11e9edbb88c51e397be1..10024e5e6521d97cd3732a7e8fd64f10ee189992 100644 (file)
@@ -117,7 +117,13 @@ func process(ctx *nncp.Ctx, path string, keep, dryRun, stdout, dumpMeta bool) bo
                        allChunksExist = false
                        continue
                }
-               if chunkNum+1 != len(chunksPaths) && uint64(fi.Size()) != metaPkt.ChunkSize {
+               var badSize bool
+               if chunkNum+1 == len(chunksPaths) {
+                       badSize = uint64(fi.Size()) != metaPkt.FileSize%metaPkt.ChunkSize
+               } else {
+                       badSize = uint64(fi.Size()) != metaPkt.ChunkSize
+               }
+               if badSize {
                        ctx.LogE("nncp-reass", nncp.SDS{
                                "path":  path,
                                "chunk": strconv.Itoa(chunkNum),