fix out of bounds access.

thx tdeval@ for mmap malloc.
okay naddy@
This commit is contained in:
espie 2004-08-16 14:58:48 +00:00
parent 295bf31885
commit eb2052e928

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-src_init_c,v 1.1 2004/08/16 14:58:48 espie Exp $
--- src/init.c.orig Fri May 19 10:44:14 1995
+++ src/init.c Mon Aug 16 16:15:46 2004
@@ -225,7 +225,7 @@ short distance (short a, short b)
#else
short distance (short a, short b)
{
- return (use_distdata ? (short)(*distdata)[(int)a][(int)b] : (short)computed_distance(a,b));
+ return (use_distdata && a < NO_SQUARES && b < NO_SQUARES ? (short)(*distdata)[(int)a][(int)b] : (short)computed_distance(a,b));
}
#endif