From 2279ab922829a58a4361eac874f78a899424c813 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Fri, 29 Dec 2023 01:51:34 +0100 Subject: Replaced strcpy() with strlcpy() --- FICS/makerank.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/FICS/makerank.c b/FICS/makerank.c index 01f95c5..dcac856 100644 --- a/FICS/makerank.c +++ b/FICS/makerank.c @@ -1,4 +1,6 @@ -/* Revised by maxxe 23/12/14 */ +/* + * Revised by maxxe 23/12/14 + */ #include #include @@ -6,6 +8,10 @@ #include #include +#if __linux__ +#include +#endif + #include "makerank.h" static ENTRY **list; @@ -72,8 +78,11 @@ GetPlayerInfo(char *fileName, ENTRY *e) printf("TROUBLE: %s's handle is " "listed as %s.\n", e->name, NameWithCase); - } else - strcpy(e->name, NameWithCase); + } else if (strlcpy(e->name, NameWithCase, + sizeof e->name) >= sizeof e->name) { + fprintf(stderr, "%s: warning: " + "strlcpy() truncated\n", __func__); + } } else if (!strcmp(field, "S_NUM:")) { sscanf(line, "%*s %d", &(e->r[0].num)); } else if (!strcmp(field, "B_NUM:")) { -- cgit v1.2.3