diff options
Diffstat (limited to 'FICS')
-rw-r--r-- | FICS/board.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/FICS/board.c b/FICS/board.c index c1980ce..33d5cd1 100644 --- a/FICS/board.c +++ b/FICS/board.c @@ -660,6 +660,7 @@ style12(game_state_t *b, move_t *ml) { char tmp[80]; int f, r; + int ret, too_long; int ws, bs; board_calc_strength(b, &ws, &bs); @@ -706,7 +707,8 @@ style12(game_state_t *b, move_t *ml) : b->lastIrreversable))); strcat(bstring, tmp); - sprintf(tmp, "%d %s %s %d %d %d %d %d %d %d %d %s (%s) %s %d\n", + ret = snprintf(tmp, sizeof tmp, "%d %s %s %d %d %d %d %d %d %d %d %s " + "(%s) %s %d\n", (b->gameNum + 1), garray[b->gameNum].white_name, garray[b->gameNum].black_name, @@ -732,6 +734,11 @@ style12(game_state_t *b, move_t *ml) : "none"), (orient == WHITE ? 0 : 1)); + too_long = (ret < 0 || (size_t)ret >= sizeof tmp); + if (too_long) { + fprintf(stderr, "FICS: %s: warning: snprintf truncated\n", + __func__); + } strcat(bstring, tmp); return 0; |