Annotation of researchv10no/local/fix.c, revision 1.1

1.1     ! root        1: #include <stdio.h>
        !             2: #include <sys/types.h>
        !             3: #include <a.out.h>
        !             4: char *malloc();
        !             5: main(argc, argv)
        !             6: char **argv;
        !             7: {
        !             8:        char *memt, *memd;
        !             9:        struct exec a;
        !            10: 
        !            11:        argc--, argv++;
        !            12:        while (argc > 0) {
        !            13:                close(0);
        !            14:                if (open(argv[0], 0) < 0)
        !            15:                        perror(argv[0]);
        !            16:                else {
        !            17:                        read(0, &a, sizeof(a));
        !            18:                        if (a.a_magic != 0413)
        !            19:                                fprintf(stderr, "%s: %o file\n", argv[0], a.a_magic);
        !            20:                        else {
        !            21:                                memt = malloc(a.a_text);
        !            22:                                memd = malloc(a.a_data);
        !            23:                                lseek(0, (long)1024, 0);
        !            24:                                read(0, memt, a.a_text);
        !            25:                                read(0, memd, a.a_data);
        !            26:                                close(1);
        !            27:                                if (creat(argv[0], 0777) < 0)
        !            28:                                        perror(argv[0]);
        !            29:                                else {
        !            30:                                        a.a_magic = 0410;
        !            31:                                        a.a_syms = 0;
        !            32:                                        write(1, &a, sizeof (a));
        !            33:                                        write(1, memt, a.a_text);
        !            34:                                        write(1, memd, a.a_data);
        !            35:                                        free(memt);
        !            36:                                        free(memd);
        !            37:                                }
        !            38:                                fprintf(stderr, "%s: fixed\n", argv[0]);
        !            39:                        }
        !            40:                }
        !            41:                argc--, argv++;
        !            42:        }
        !            43: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.