/* correct-i386-2.c Corrects the Debian 2.2 rev0 i386 Binary-2 CD for a single-bit error. COMPILE: gcc -Wall -O2 -o correct-i386-2 correct-i386-2.c USAGE: ./correct-i386-2 binary-i386-2.iso NOTE: This is an in-place correction - it doesn't require any disk space. Old md5sum: c4a8591b64efe58e0acd39f7eac30ac6 binary-i386-2.iso New md5sum: be04cd6d17159d66978ad227b26ed17d binary-i386-2.iso Copyright (C) 2000 J.A. Bezemer Licensed under GNU GPL -- NO WARRANTY WHATSOEVER -- USE AT YOUR OWN RISK! */ #include #define POS 0x148554de /* Or 0x64de to correct pdksh_5.2.14-1.deb when copied from the CD */ #define OLD 0xc8 #define NEW 0xc0 int main (int argc, char *argv[]) { FILE *f; unsigned char o, n = NEW; if (argc == 2 && (f = fopen (argv[1], "r+")) != NULL && fseek (f, POS, SEEK_SET) == 0 && fread (&o, 1, 1, f) == 1 && o == OLD && fseek (f, POS, SEEK_SET) == 0 && fwrite (&n, 1, 1, f) == 1 && fclose (f) == 0) { fprintf (stderr, "Correction successful\n"); return 0; } else { fprintf (stderr, "Usage error, file error, wrong file or already " "converted file\n"); perror ("This may be the error message"); return 1; } }