瀏覽代碼

repo/download: fix for downloading zero bytes files. (#4436)

Allocated buffer served to client and not properly truncated to
number of bytes read.

Signed-off-by: Jonas Östanbäck <jonas.ostanback@gmail.com>
Jonas Östanbäck 7 年之前
父節點
當前提交
9085c3b73d
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      routers/repo/download.go

+ 1 - 1
routers/repo/download.go

@@ -18,7 +18,7 @@ import (
 func ServeData(ctx *context.Context, name string, reader io.Reader) error {
 	buf := make([]byte, 1024)
 	n, _ := reader.Read(buf)
-	if n > 0 {
+	if n >= 0 {
 		buf = buf[:n]
 	}