From 28cf96e157e62a566454b3a5b72ebd41fcc7258e Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 3 Nov 2016 09:57:51 +0100 Subject: [PATCH] enforce nickname character limit in credit manager fixes #1 --- src/credit_manager.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/credit_manager.c b/src/credit_manager.c index a8a8e3a..8017524 100644 --- a/src/credit_manager.c +++ b/src/credit_manager.c @@ -103,14 +103,14 @@ static void new_credit(void) { } clrscr(); - cprintf("\rNickname:\r\n"); + cprintf("\rNickname (max. 10 Zeichen):\r\n"); if ((input = get_input()) == NULL || *input == '\0') return; name = strdup(input); cprintf("\r\nGuthaben in Cents:\r\n"); if ((input = get_input()) == NULL || *input == '\0' || (credit = atoi(input)) == 0) return; - strcpy(credits.credits[credits.num_items].nickname, name); + strncpy(credits.credits[credits.num_items].nickname, name, NICKNAME_MAX_LEN); credits.credits[credits.num_items].credit = credit; time = get_time(); -- 2.39.5