Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "invalid distance code" with large backups #1

Open
josvos opened this issue Apr 27, 2022 · 5 comments
Open

Error "invalid distance code" with large backups #1

josvos opened this issue Apr 27, 2022 · 5 comments

Comments

@josvos
Copy link

josvos commented Apr 27, 2022

ab-decrypt works fine for small .ab files, but for large .ab files, e.g. a backup of 317 MB, I get at some point:

 zlib.error: Error -3 while decompressing data: invalid distance code

The partly written tar output file is ok for the part it already wrote (284 MB in case of the 317 MB backup), but it is incomplete.

This is with ab-decrypt 1.0.0 (pip install in a Pythoin 3.9.12 venv).

@joernheissler
Copy link
Owner

Hi,
can you try to supply a parameter to decompressobj? Perhaps try all values from range(-15, 48) in a loop and see which ones work. Or try 0 first.

@josvos
Copy link
Author

josvos commented Apr 27, 2022

Hi,

Values 0 and 15 give the same error as with no value (and produce the same tarball). All other values produce an empty tarball and give one of these errors:

zlib.error: Error -3 while decompressing data: invalid stored block lengths
zlib.error: Error -3 while decompressing data: invalid window size
zlib.error: Error -3 while decompressing data: incorrect header check

@joernheissler
Copy link
Owner

Is the backup encrypted? If not, please do encrypt it.
For larger backups (4-5 GiB) I get Invalid padding bytes which sounds like either an interrupted transfer or a bug in android.

@josvos
Copy link
Author

josvos commented Apr 28, 2022

Is the backup encrypted?

Yes, it is.

@joernheissler
Copy link
Owner

I'm unable to reproduce the issue.

You could modify the code to not decompress the backup, i.e. it outputs compressed data. Then try using this java program to decompress your backup:

import java.util.zip.Inflater;
import java.util.zip.InflaterOutputStream;
import java.io.BufferedOutputStream;

public class Inflate
{
    public static void main(String[] args) throws Exception
    {
        Inflater inflater = new Inflater();
        InflaterOutputStream stream = new InflaterOutputStream(System.out, inflater);
        byte[] buf = new byte[4096];
        for (;;) {
            int len = System.in.read(buf);
            if (len < 0) {
                break;
            }
            stream.write(buf, 0, len);
        }
        stream.flush();
        stream.close();
    }
}

If that gives the same error I assume there's a transmission error (CBC encryption mode wouldn't detect this!) or a bug in your android version.
But if it works the bug might be in my python program or somewhere in python or zlib. But to investigate further, I'd still need some way to reproduce this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants