From db0349ae13af260687347064b71127e53b03b0b0 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Fri, 9 Jan 2026 14:03:32 +0100 Subject: parse_ini: correct string length --- lib/parse_ini.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/parse_ini.c b/lib/parse_ini.c index db337622..196cac79 100644 --- a/lib/parse_ini.c +++ b/lib/parse_ini.c @@ -352,15 +352,17 @@ static int add_option(FILE *filePointer, np_arg_list **optlst) { optnew->next = NULL; read_pos = 0; - optnew->arg = malloc(cfg_len + 1); + size_t arg_length = cfg_len + 1; + optnew->arg = malloc(arg_length); /* 1-character params needs only one dash */ if (opt_len == 1) { - strncpy(&optnew->arg[read_pos], "-", 1); + strncpy(&optnew->arg[read_pos], "-", arg_length); read_pos += 1; } else { - strncpy(&optnew->arg[read_pos], "--", 2); + strncpy(&optnew->arg[read_pos], "--", arg_length); read_pos += 2; } + strncpy(&optnew->arg[read_pos], optptr, opt_len); read_pos += opt_len; if (value) { -- cgit v1.2.3-74-g34f1