diff options
Diffstat (limited to 'games/adventure/save.c')
-rw-r--r-- | games/adventure/save.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/games/adventure/save.c b/games/adventure/save.c index 6784fef..763e56b 100644 --- a/games/adventure/save.c +++ b/games/adventure/save.c @@ -108,7 +108,7 @@ struct savestruct save_array[] = dseen, sizeof(dseen), fixed, sizeof(fixed), hinted, sizeof(hinted), - link, sizeof(link), + linkx, sizeof(linkx), odloc, sizeof(odloc), place, sizeof(place), prop, sizeof(prop), @@ -125,24 +125,23 @@ char *outfile; /* to output the data using checksum to start random #s */ char *s; long sum; int i; - uid_t euid_save; crc_start(); for (p = save_array; p->address != NULL; p++) sum = crc(p->address, p->width); srandom((int) sum); - euid_save = geteuid(); - seteuid(getuid()); - + setegid(egid); if ((out = fopen(outfile, "wb")) == NULL) { fprintf(stderr, "Hmm. The name \"%s\" appears to be magically blocked.\n", outfile); - seteuid(euid_save); + setegid(getgid()); return 1; } + setegid(getgid()); + fwrite(&sum, sizeof(sum), 1, out); /* Here's the random() key */ for (p = save_array; p->address != NULL; p++) { @@ -151,7 +150,6 @@ char *outfile; /* to output the data using checksum to start random #s */ fwrite(p->address, p->width, 1, out); } fclose(out); - seteuid(euid_save); return 0; } @@ -163,19 +161,18 @@ char *infile; char *s; long sum, cksum; int i; - uid_t euid_save; - - euid_save = geteuid(); - seteuid(euid_save); + setegid(egid); if ((in = fopen(infile, "rb")) == NULL) { fprintf(stderr, "Hmm. The file \"%s\" appears to be magically blocked.\n", infile); - seteuid(euid_save); + setegid(getgid()); return 1; } + setegid(getgid()); + fread(&sum, sizeof(sum), 1, in); /* Get the seed */ srandom((int) sum); for (p = save_array; p->address != NULL; p++) @@ -185,7 +182,6 @@ char *infile; *s = (*s ^ random()) & 0xFF; /* Lightly decrypt */ } fclose(in); - seteuid(euid_save); crc_start(); /* See if she cheated */ for (p = save_array; p->address != NULL; p++) |