Browse Source

[GINR] Ensure entire git blobs are read

cgars 7 năm trước cách đây
mục cha
commit
a6216a6472
1 tập tin đã thay đổi với 3 bổ sung3 xóa
  1. 3 3
      routes/repo/view.go

+ 3 - 3
routes/repo/view.go

@@ -246,7 +246,9 @@ func renderFile(c *context.Context, entry *git.TreeEntry, treeLink, rawLink stri
 			if blob.Size() > 1024 {
 				d := make([]byte, blob.Size()-
 					1024)
-				r.Read(d)
+				if _, err := io.ReadAtLeast(r, d, int(blob.Size()-1024)); err != nil {
+					log.Error(4., "Could nor read all of a git file:%+v", err)
+				}
 				buf = append(buf, d...)
 			}
 		} else {
@@ -279,8 +281,6 @@ func renderFile(c *context.Context, entry *git.TreeEntry, treeLink, rawLink stri
 			} else {
 				fileContent = content
 			}
-			fileContent = string(buf)
-			log.Trace("Buffer Size is: %d", len(buf))
 			var output bytes.Buffer
 			lines := strings.Split(fileContent, "\n")
 			if len(lines) > setting.UI.MaxLineHighlight {