Browse Source

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>
pull/4517/merge
Jonas Östanbäck 8 years ago committed by 无闻
parent
commit
9085c3b73d
  1. 2
      routers/repo/download.go

2
routers/repo/download.go

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

Loading…
Cancel
Save