Fix crash on reading some FENs
authorH.G.Muller <hgm@hgm-xboard.(none)>
Mon, 2 Jun 2014 17:34:47 +0000 (19:34 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Mon, 2 Jun 2014 17:34:47 +0000 (19:34 +0200)
It was possible to read beyond the end of a FEN when converting it to
internal format, which could lead to all kind of nastiness.

hachu.c

diff --git a/hachu.c b/hachu.c
index 711ec43..0eea758 100644 (file)
--- a/hachu.c
+++ b/hachu.c
@@ -2318,6 +2318,7 @@ Convert (char *fen)
         *p++ = table[2* (*fen - 'A' - n)+1] + n;\r
       }\r
     } else *p++ = *fen;\r
+    if(!*fen) break;\r
     fen++;\r
   }\r
   printf("# converted FEN '%s'\n", fenArray);\r