From: Fabian Fichter Date: Sun, 19 Mar 2023 19:27:56 +0000 (+0100) Subject: Skip parsing invalid squares (#599) X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=6ed6c3eb2677c0d81f4ab13f7aec6ed3813cc3d6;p=fairystockfish.git Skip parsing invalid squares (#599) --- diff --git a/src/parser.cpp b/src/parser.cpp index 59c22ab..28104e7 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -115,7 +115,11 @@ namespace { std::stringstream ss(value); target = 0; while (!ss.eof() && ss >> file && ss >> rank) + { + if (Rank(rank - 1) > RANK_MAX || (file != '*' && File(tolower(file) - 'a') > FILE_MAX)) + return false; target |= file == '*' ? rank_bb(Rank(rank - 1)) : square_bb(make_square(File(tolower(file) - 'a'), Rank(rank - 1))); + } return !ss.fail(); }