aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2024-01-06 11:35:05 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2024-01-06 11:35:05 +0100
commit2f68b00b47e6a046e99aa9528d86f8f49e2913c9 (patch)
tree152b0eccc3d9a300162a7a5d6e13ccde89547bad
parentb8f6d0ac5bc2880413756e9a6b536c0d671a1c7e (diff)
Replaced strcpy() calls using strlcpy()
-rw-r--r--FICS/algcheck.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/FICS/algcheck.c b/FICS/algcheck.c
index c42f880..b047a85 100644
--- a/FICS/algcheck.c
+++ b/FICS/algcheck.c
@@ -31,6 +31,10 @@
#include "movecheck.h"
#include "utils.h"
+#if __linux__
+#include <bsd/string.h>
+#endif
+
/* Well, lets see if I can list the possibilities
* Piece moves
* Ne4
@@ -87,7 +91,7 @@ get_move_info(char *str, int *piece, int *ff, int *fr, int *tf, int *tr,
int matchVal = -1;
*bishconfusion = 0;
- strcpy(tmp, str);
+ strlcpy(tmp, str, sizeof tmp);
if ((s = strchr(tmp, '+')) != NULL) { // Cut off any check marks
*s = '\0';
@@ -435,43 +439,43 @@ alg_unparse(game_state_t *gs, move_t *mt)
}
if (piece == KING && (mt->fromFile == 4 && mt->toFile == 6)) {
- strcpy(mStr, "O-O");
+ strlcpy(mStr, "O-O", sizeof mStr);
goto check;
}
if (piece == KING && (mt->fromFile == 4 && mt->toFile == 2)) {
- strcpy(mStr, "O-O-O");
+ strlcpy(mStr, "O-O-O", sizeof mStr);
goto check;
}
- strcpy(mStr, "");
+ mStr[0] = '\0';
switch (piece) {
case PAWN:
if (mt->fromFile == ALG_DROP) {
- strcpy(mStr,"P");
+ strlcpy(mStr, "P", sizeof mStr);
} else if (mt->fromFile != mt->toFile) {
snprintf(tmp, sizeof tmp, "%c", (mt->fromFile + 'a'));
- strcpy(mStr, tmp);
+ strlcpy(mStr, tmp, sizeof mStr);
}
break;
case KNIGHT:
- strcpy(mStr, "N");
+ strlcpy(mStr, "N", sizeof mStr);
break;
case BISHOP:
- strcpy(mStr, "B");
+ strlcpy(mStr, "B", sizeof mStr);
break;
case ROOK:
- strcpy(mStr, "R");
+ strlcpy(mStr, "R", sizeof mStr);
break;
case QUEEN:
- strcpy(mStr, "Q");
+ strlcpy(mStr, "Q", sizeof mStr);
break;
case KING:
- strcpy(mStr, "K");
+ strlcpy(mStr, "K", sizeof mStr);
break;
default:
- strcpy(mStr, "");
+ strlcpy(mStr, "", sizeof mStr);
break;
} /* switch */