Avoid one case of getting out of synch and trying to read too much.
authorDebora Wöpcke <deboradub@gmail.com>
Sat, 6 Jun 2015 19:06:54 +0000 (21:06 +0200)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Wed, 14 Oct 2015 18:47:01 +0000 (20:47 +0200)
Signed-off-by: David ‘Bombe’ Roden <bombe@freenetproject.org>
src/main/java/net/pterodactylus/fcp/FcpUtils.java

index 415cf1a..26a407c 100644 (file)
@@ -268,7 +268,9 @@ public class FcpUtils {
                                throw new EOFException("stream reached eof");
                        }
                        destination.write(buffer, 0, read);
-                       remaining -= read;
+                       if (remaining > 0) {
+                               remaining -= read;
+                       }
                }
        }