From 9810fdcbfd0b0566374089e03748106224bbdef8 Mon Sep 17 00:00:00 2001 From: Lucas Brutschy Date: Thu, 26 Aug 2021 13:15:35 +0200 Subject: [PATCH] Remove zero bytes after diff and extra data jbsdiff seems to write one extra zero byte for every byte in the target binary to the compressed stream. While these are mostly compressed away, it will still make the patches slightly smaller and the patching slightly faster to not write them. This should make jbsdiff's patches more similar to those generated by bsdiff. However, even after this change, both library seem to generate slighly different patch files. --- src/main/java/io/sigpipe/jbsdiff/Diff.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/sigpipe/jbsdiff/Diff.java b/src/main/java/io/sigpipe/jbsdiff/Diff.java index df3f086..2b9033a 100644 --- a/src/main/java/io/sigpipe/jbsdiff/Diff.java +++ b/src/main/java/io/sigpipe/jbsdiff/Diff.java @@ -225,13 +225,13 @@ public static void diff(byte[] oldBytes, byte[] newBytes, OutputStream out, patchOut = compressor.createCompressorOutputStream(compression, byteOut); - patchOut.write(db); + patchOut.write(db, 0, dblen); patchOut.close(); header.setDiffLength(byteOut.size() - header.getControlLength()); patchOut = compressor.createCompressorOutputStream(compression, byteOut); - patchOut.write(eb); + patchOut.write(eb, 0, eblen); patchOut.close(); header.setOutputLength(newBytes.length);