summaryrefslogtreecommitdiffstats
path: root/lib/parse_ini.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/parse_ini.c')
-rw-r--r--lib/parse_ini.c8
1 files changed, 5 insertions, 3 deletions
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) {
352 optnew->next = NULL; 352 optnew->next = NULL;
353 353
354 read_pos = 0; 354 read_pos = 0;
355 optnew->arg = malloc(cfg_len + 1); 355 size_t arg_length = cfg_len + 1;
356 optnew->arg = malloc(arg_length);
356 /* 1-character params needs only one dash */ 357 /* 1-character params needs only one dash */
357 if (opt_len == 1) { 358 if (opt_len == 1) {
358 strncpy(&optnew->arg[read_pos], "-", 1); 359 strncpy(&optnew->arg[read_pos], "-", arg_length);
359 read_pos += 1; 360 read_pos += 1;
360 } else { 361 } else {
361 strncpy(&optnew->arg[read_pos], "--", 2); 362 strncpy(&optnew->arg[read_pos], "--", arg_length);
362 read_pos += 2; 363 read_pos += 2;
363 } 364 }
365
364 strncpy(&optnew->arg[read_pos], optptr, opt_len); 366 strncpy(&optnew->arg[read_pos], optptr, opt_len);
365 read_pos += opt_len; 367 read_pos += opt_len;
366 if (value) { 368 if (value) {