mirror of
https://github.com/gogs/gogs.git
synced 2025-05-31 11:42:13 +00:00
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>
This commit is contained in:
parent
306ba917ea
commit
9085c3b73d
@ -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…
x
Reference in New Issue
Block a user