diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2024-05-20 00:26:01 +0200 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2024-05-20 00:26:01 +0200 |
commit | 679bf294d1a0924d7783ab6748f1ff327200373b (patch) | |
tree | 48ccf3f3753b66baa0a9e5eb2758e5665a5e89f0 /FICS/gamedb.c | |
parent | 9a6f35d1144f9f50bcc138716e91666af257d439 (diff) |
Size-bounded string copying
Diffstat (limited to 'FICS/gamedb.c')
-rw-r--r-- | FICS/gamedb.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/FICS/gamedb.c b/FICS/gamedb.c index f8da9fd..7b1d44e 100644 --- a/FICS/gamedb.c +++ b/FICS/gamedb.c @@ -44,6 +44,10 @@ #include "rmalloc.h" #include "utils.h" +#if __linux__ +#include <bsd/string.h> +#endif + /* * This should be enough to hold any game up to at least 250 moves. If * we overwrite this, the server will crash. @@ -206,7 +210,7 @@ game_time_str(int wt, int winc, int bt, int binc) static char tstr[50] = { '\0' }; if ((!wt) && (!winc)) { // Untimed - strcpy(tstr, ""); + (void) strlcpy(tstr, "", sizeof tstr); return tstr; } @@ -1142,13 +1146,13 @@ ReadOneV1Move(FILE *fp, move_t *m) PieceChar = PieceToChar(piecetype(piece) | WHITE); if (PieceChar == 'K' && m->fromFile == 4 && m->toFile == 6) { - strcpy(m->algString, "O-O"); - strcpy(m->moveString, "o-o"); + mstrlcpy(m->algString, "O-O", sizeof(m->algString)); + mstrlcpy(m->moveString, "o-o", sizeof(m->moveString)); } else if (PieceChar == 'K' && m->fromFile == 4 && m->toFile == 2) { - strcpy(m->algString, "O-O-O"); - strcpy(m->moveString, "o-o-o"); + mstrlcpy(m->algString, "O-O-O", sizeof(m->algString)); + mstrlcpy(m->moveString, "o-o-o", sizeof(m->moveString)); } else { i = 0; m->algString[i++] = PieceChar; |