From 24e2f5f6da5cb4f5d0b45db138242e0168171708 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Tue, 9 Jul 2024 01:07:19 +0200 Subject: Changed set_interface() --- FICS/variable.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'FICS') diff --git a/FICS/variable.c b/FICS/variable.c index f8a4014..532243c 100644 --- a/FICS/variable.c +++ b/FICS/variable.c @@ -33,6 +33,8 @@ #include "stdinclude.h" #include "common.h" +#include + #include "board.h" #include "command.h" #include "comproc.h" @@ -404,13 +406,23 @@ set_inc(int p, char *var, char *val) PRIVATE int set_interface(int p, char *var, char *val) { -// int v = -1; + bool truncated = false; + char *cp; + size_t size; - if (!val) + if (val == NULL || strcmp(val, "") == 0) return VAR_BADVAL; -// parray[p].xxx = v; - pprintf(p, "Interface set to %s.\n", val); + cp = &(parray[p].interface[0]); + size = ARRAY_SIZE(parray[p].interface); + + if (strlcpy(cp, val, size) >= size) + truncated = true; + + pprintf(p, "Interface set to %s.\n", cp); + + if (truncated) + pprintf(p, "Interface was truncated!\n"); return VAR_OK; } -- cgit v1.2.3