summaryrefslogtreecommitdiffstats
path: root/rogue/inventory.c
diff options
context:
space:
mode:
authormrg <mrg@NetBSD.org>2002-10-01 14:18:57 +0000
committermrg <mrg@NetBSD.org>2002-10-01 14:18:57 +0000
commita07de2b816b2a6d7b25bffefd1239db80d85f6d7 (patch)
tree06062ea06a61f0b7694f7d9fc038ab912c9f3a9e /rogue/inventory.c
parente0b92fed06e8d627affa09e5138e4ccef985b6ad (diff)
downloadbsdgames-darwin-a07de2b816b2a6d7b25bffefd1239db80d85f6d7.tar.gz
bsdgames-darwin-a07de2b816b2a6d7b25bffefd1239db80d85f6d7.zip
- use correctly bounded strings when reloading a saved game. in particular,
do not let the save game file "string length" exceed the amount of space supplied. as noted by <stanojr@iserver.sk> on bugtraq. - minor KNF. tested by simonb.
Diffstat (limited to 'rogue/inventory.c')
-rw-r--r--rogue/inventory.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/rogue/inventory.c b/rogue/inventory.c
index 1293765d..ed0f9337 100644
--- a/rogue/inventory.c
+++ b/rogue/inventory.c
@@ -1,4 +1,4 @@
-/* $NetBSD: inventory.c,v 1.7 2002/07/07 09:35:08 tron Exp $ */
+/* $NetBSD: inventory.c,v 1.8 2002/10/01 14:18:57 mrg Exp $ */
/*
* Copyright (c) 1988, 1993
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)inventory.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: inventory.c,v 1.7 2002/07/07 09:35:08 tron Exp $");
+__RCSID("$NetBSD: inventory.c,v 1.8 2002/10/01 14:18:57 mrg Exp $");
#endif
#endif /* not lint */
@@ -421,14 +421,14 @@ void
mix_colors()
{
short i, j, k;
- char *t;
+ char t[MAX_ID_TITLE_LEN];
for (i = 0; i <= 32; i++) {
j = get_rand(0, (POTIONS - 1));
k = get_rand(0, (POTIONS - 1));
- t = id_potions[j].title;
- id_potions[j].title = id_potions[k].title;
- id_potions[k].title = t;
+ memcpy(t, id_potions[j].title, MAX_ID_TITLE_LEN);
+ memcpy(id_potions[j].title, id_potions[k].title, MAX_ID_TITLE_LEN);
+ memcpy(id_potions[k].title, t, MAX_ID_TITLE_LEN);
}
}