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:38:48 +0000 (20:38 +0200)
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;
+                       }
                }
        }