summaryrefslogtreecommitdiff
path: root/games/adventure/crc.c
diff options
context:
space:
mode:
authorStuart Henderson <sthen@cvs.openbsd.org>2008-10-03 08:18:45 +0000
committerStuart Henderson <sthen@cvs.openbsd.org>2008-10-03 08:18:45 +0000
commit06fd7197830474b99ed18abf30aeac5f564e76bf (patch)
treedf3ddc3b741d1292b0e6967233727a52e080df00 /games/adventure/crc.c
parentde488b267d2252ee7bce9afcebd3687ddb07a80c (diff)
Mask crcval in the right place, avoiding segfault during save
on 64-bit arch. (The save format is not portable, however). Looks right to deraadt@.
Diffstat (limited to 'games/adventure/crc.c')
-rw-r--r--games/adventure/crc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/games/adventure/crc.c b/games/adventure/crc.c
index 0f5720f5815..1e62d03a369 100644
--- a/games/adventure/crc.c
+++ b/games/adventure/crc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crc.c,v 1.5 2004/07/09 15:59:26 deraadt Exp $ */
+/* $OpenBSD: crc.c,v 1.6 2008/10/03 08:18:44 sthen Exp $ */
/* $NetBSD: crc.c,v 1.2 1995/03/21 12:04:59 cgd Exp $ */
/*-
@@ -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
-static char rcsid[] = "$OpenBSD: crc.c,v 1.5 2004/07/09 15:59:26 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: crc.c,v 1.6 2008/10/03 08:18:44 sthen Exp $";
#endif
#endif /* not lint */
@@ -130,7 +130,7 @@ crc(const char *ptr, int nr)
if (step >= sizeof(crctab) / sizeof(crctab[0]))
step = 0;
}
- crcval = (crcval << 8) ^ crctab[i];
+ crcval = ((crcval << 8) ^ crctab[i]) & 0xffffffff;
}
- return crcval & 0xffffffff; /* Mask to 32 bits. */
+ return crcval;
}