Invalid compressed data--format violated?

Alternative Location of Gzip's fixgz Utility

In case you can no longer find fixgz on gzip.org's website, here is a link to a version available on archive.org: https://web.archive.org/web/20180624175352/http://www.gzip.org/fixgz.zip.

Source Code for fixgz Utility

Also, in case that disappears as well, below is the source code for the fixgz utility:

/* fixgz attempts to fix a binary file transferred in ascii mode by
 * removing each extra CR when it followed by LF.
 * usage: fixgz  bad.gz fixed.gz

 * Copyright 1998 Jean-loup Gailly <[email protected]>
 *   This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the author be held liable for any damages
 * arising from the use of this software.

 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely.
 */

#include <stdio.h>

int main(argc, argv)
     int argc;
     char **argv;
{
    int c1, c2; /* input bytes */
    FILE *in;   /* corrupted input file */
    FILE *out;  /* fixed output file */

    if (argc <= 2) {
    fprintf(stderr, "usage: fixgz bad.gz fixed.gz\n");
    exit(1);
    }
    in  = fopen(argv[1], "rb");
    if (in == NULL) {
    fprintf(stderr, "fixgz: cannot open %s\n", argv[1]);
    exit(1);
    }
    out = fopen(argv[2], "wb");
    if (in == NULL) {
    fprintf(stderr, "fixgz: cannot create %s\n", argv[2]);
    exit(1);
    }

    c1 = fgetc(in);

    while ((c2 = fgetc(in)) != EOF) {
    if (c1 != '\r' || c2 != '\n') {
        fputc(c1, out);
    }
    c1 = c2;
    }
    if (c1 != EOF) {
    fputc(c1, out);
    }
    exit(0);
    return 0; /* avoid warning */
}


Your command is correct. But it seems the file is corrupted. It's easy to tell, when some files are correctly extracted (for example ./dokuwiki/.htaccess.dist), but not the rest.

Recreate the dokuwiki.20151010.tar.gz file, and make sure it doesn't report errors while doing so. If you downloaded the file from somewhere, verify the checksum, or at least the file size.

The bottomline is, either the file was incorrectly created or downloaded. The command you have should work fine with a .tar.gz file.

Tags:

Linux

Bash

Tar