|
|
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 != 0410) ! 19: fprintf(stderr, "%s: %o file\n", ! 20: argv[0], a.a_magic); ! 21: else { ! 22: int i = (a.a_text+1023)&~1023; ! 23: int j = (a.a_text+511)&~511; ! 24: printf("old way bnd %d, new way %d\n", j, i); ! 25: if (j == i) { ! 26: printf("ok as is\n"); ! 27: goto easy; ! 28: } ! 29: memt = malloc(a.a_text+1024); ! 30: memd = malloc(a.a_data); ! 31: read(0, memt, a.a_text); ! 32: read(0, memd, a.a_data); ! 33: close(1); ! 34: if (creat(argv[0], 0777) < 0) ! 35: perror(argv[0]); ! 36: else { ! 37: a.a_syms = 0; ! 38: a.a_text = i; ! 39: write(1, &a, sizeof (a)); ! 40: write(1, memt, i); ! 41: write(1, memd, a.a_data); ! 42: free(memt); ! 43: free(memd); ! 44: } ! 45: fprintf(stderr, "%s: fixed\n", argv[0]); ! 46: } ! 47: } ! 48: easy: ! 49: argc--, argv++; ! 50: } ! 51: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.