forked from TrueCloudLab/distribution
read the actual number of bytes according to the initial size.
Signed-off-by: yuzou <zouyu7@huawei.com>
This commit is contained in:
parent
c149d45cc8
commit
44c0b9ae87
1 changed files with 5 additions and 1 deletions
|
@ -1184,7 +1184,11 @@ func (rr *randReader) Read(p []byte) (n int, err error) {
|
||||||
rr.m.Lock()
|
rr.m.Lock()
|
||||||
defer rr.m.Unlock()
|
defer rr.m.Unlock()
|
||||||
|
|
||||||
n = copy(p, randomContents(int64(len(p))))
|
toread := int64(len(p))
|
||||||
|
if toread > rr.r {
|
||||||
|
toread = rr.r
|
||||||
|
}
|
||||||
|
n = copy(p, randomContents(toread))
|
||||||
rr.r -= int64(n)
|
rr.r -= int64(n)
|
||||||
|
|
||||||
if rr.r <= 0 {
|
if rr.r <= 0 {
|
||||||
|
|
Loading…
Reference in a new issue