diff options
author | dholland <dholland@NetBSD.org> | 2012-01-07 18:08:35 +0000 |
---|---|---|
committer | dholland <dholland@NetBSD.org> | 2012-01-07 18:08:35 +0000 |
commit | 7af3623528af2b5ce6d4f0a0341cf9e78b5dc28f (patch) | |
tree | 48b10646e28d32a23db6d174c137289084f45ae4 /adventure | |
parent | b187ced51d84335ab15f55b5ea14a132c7c54829 (diff) | |
download | bsdgames-darwin-7af3623528af2b5ce6d4f0a0341cf9e78b5dc28f.tar.gz bsdgames-darwin-7af3623528af2b5ce6d4f0a0341cf9e78b5dc28f.tar.zst bsdgames-darwin-7af3623528af2b5ce6d4f0a0341cf9e78b5dc28f.zip |
Make this not crash on machines that are (a) 64 bit, or (b) have signed
chars by default (i.e., almost all machines). Makes it possible to save
the game. This has been broken since 4.4 and probably ever since the
FORTRAN -> C translation.
Crash reported by Petri Laakso in private mail.
Diffstat (limited to 'adventure')
-rw-r--r-- | adventure/crc.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/adventure/crc.c b/adventure/crc.c index d429e912..8626f348 100644 --- a/adventure/crc.c +++ b/adventure/crc.c @@ -1,4 +1,4 @@ -/* $NetBSD: crc.c,v 1.11 2009/08/25 06:04:17 dholland Exp $ */ +/* $NetBSD: crc.c,v 1.12 2012/01/07 18:08:35 dholland Exp $ */ /*- * Copyright (c) 1993 @@ -38,7 +38,7 @@ static char sccsid[] = "@(#)crc.c 8.1 (Berkeley) 5/31/93"; static char ORIGINAL_sccsid[] = "@(#)crc.c 5.2 (Berkeley) 4/4/91"; #else -__RCSID("$NetBSD: crc.c,v 1.11 2009/08/25 06:04:17 dholland Exp $"); +__RCSID("$NetBSD: crc.c,v 1.12 2012/01/07 18:08:35 dholland Exp $"); #endif #endif /* not lint */ @@ -124,13 +124,8 @@ crc(const char *ptr, int nr) while (nr > 0) for (p = ptr; nr--; ++p) { - /* - * The following is not portable to machines - * where char is unsigned, because of sign - * extension. But it can't be changed without - * breaking save files. Sigh. - */ - if (!(i = crcval >> 24 ^ *p)) { + i = (crcval >> 24 ^ (unsigned char)*p) & 0xff; + if (i == 0) { i = step++; if (step >= sizeof(crctab) / sizeof(crctab[0])) step = 0; |