Fix CID 338446: Buffer not null terminated (BUFFER_SIZE)

buffer_size_warning: Calling strncpy with a maximum size argument of 1024 bytes on destination array <unnamed>::StartFEN of size 1024 bytes might leave the destination string unterminated.
This commit is contained in:
Calcitem 2021-08-14 10:54:25 +08:00
parent a8ef258468
commit 5847787e5b
No known key found for this signature in database
GPG Key ID: F2F7C29E054CFB80
1 changed files with 6 additions and 4 deletions

View File

@ -162,22 +162,24 @@ void UCI::loop(int argc, char *argv[])
switch (rule.piecesCount) { switch (rule.piecesCount) {
case 9: case 9:
strncpy(StartFEN, StartFEN9, BUFSIZ); strncpy(StartFEN, StartFEN9, BUFSIZ - 1);
break; break;
case 10: case 10:
strncpy(StartFEN, StartFEN10, BUFSIZ); strncpy(StartFEN, StartFEN10, BUFSIZ - 1);
break; break;
case 11: case 11:
strncpy(StartFEN, StartFEN11, BUFSIZ); strncpy(StartFEN, StartFEN11, BUFSIZ - 1);
break; break;
case 12: case 12:
strncpy(StartFEN, StartFEN12, BUFSIZ); strncpy(StartFEN, StartFEN12, BUFSIZ - 1);
break; break;
default: default:
assert(0); assert(0);
break; break;
} }
StartFEN[BUFSIZ - 1] = '\0';
pos->set(StartFEN, Threads.main()); pos->set(StartFEN, Threads.main());
for (int i = 1; i < argc; ++i) for (int i = 1; i < argc; ++i)