diff options
author | Thomas Wolf <thomas.wolf@paranor.ch> | 2021-01-29 23:02:30 +0100 |
---|---|---|
committer | Thomas Wolf <thomas.wolf@paranor.ch> | 2021-01-31 10:31:10 +0100 |
commit | 91ddc0e28435fbd96350a7a0a75df0f9dd8fe133 (patch) | |
tree | 540cf0dee7159feb346a2c8a875e4563f7c4c94f /org.eclipse.jgit | |
parent | aa052ea09956385f5b90130f63ad4b07a3dee8c7 (diff) | |
download | jgit-91ddc0e28435fbd96350a7a0a75df0f9dd8fe133.tar.gz jgit-91ddc0e28435fbd96350a7a0a75df0f9dd8fe133.zip |
IO: fix IO.readFully(InputStream, byte[], int)
This would run into an endless loop if the offset given was not zero.
Fix the logic to exit the read loop when the buffer is full.
Luckily all existing uses of this method call it only with offset zero.
Change-Id: I0ec2a4fb43efe4a605d06ac2e88cf155d50e2f1e
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java index 680d90392d..6d5694e435 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java @@ -246,7 +246,7 @@ public class IO { * buffer that must be fully populated, [off, off+len). * @param off * position within the buffer to start writing to. - * @return number of bytes in buffer or stream, whichever is shortest + * @return number of bytes read * @throws java.io.IOException * there was an error reading from the stream. */ @@ -254,8 +254,8 @@ public class IO { throws IOException { int r; int len = 0; - while ((r = fd.read(dst, off, dst.length - off)) >= 0 - && len < dst.length) { + while (off < dst.length + && (r = fd.read(dst, off, dst.length - off)) >= 0) { off += r; len += r; } |