Use strncpy() properly in general_option_edit()
Always use strncpy() to copy strings between fixed-size buffers and pass the buffer size as maximal length parameter. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
578091f051
commit
6521d8cc0a
14
src/custom.c
14
src/custom.c
@ -739,11 +739,11 @@ static void general_option_edit(int i)
|
|||||||
break;
|
break;
|
||||||
case OUTPUT_DATE_FMT:
|
case OUTPUT_DATE_FMT:
|
||||||
status_mesg(output_datefmt_str, "");
|
status_mesg(output_datefmt_str, "");
|
||||||
strncpy(buf, conf.output_datefmt,
|
strncpy(buf, conf.output_datefmt, BUFSIZ);
|
||||||
strlen(conf.output_datefmt) + 1);
|
buf[BUFSIZ - 1] = '\0';
|
||||||
if (updatestring(win[STA].p, &buf, 0, 1) == 0) {
|
if (updatestring(win[STA].p, &buf, 0, 1) == 0) {
|
||||||
strncpy(conf.output_datefmt, buf,
|
strncpy(conf.output_datefmt, buf, BUFSIZ);
|
||||||
strlen(buf) + 1);
|
conf.output_datefmt[BUFSIZ - 1] = '\0';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INPUT_DATE_FMT:
|
case INPUT_DATE_FMT:
|
||||||
@ -755,9 +755,11 @@ static void general_option_edit(int i)
|
|||||||
break;
|
break;
|
||||||
case DAY_HEADING_FMT:
|
case DAY_HEADING_FMT:
|
||||||
status_mesg(output_datefmt_str, "");
|
status_mesg(output_datefmt_str, "");
|
||||||
strcpy(buf, conf.day_heading);
|
strncpy(buf, conf.day_heading, BUFSIZ);
|
||||||
|
buf[BUFSIZ - 1] = '\0';
|
||||||
if (updatestring(win[STA].p, &buf, 0, 1) == 0) {
|
if (updatestring(win[STA].p, &buf, 0, 1) == 0) {
|
||||||
strcpy(conf.day_heading, buf);
|
strncpy(conf.day_heading, buf, BUFSIZ);
|
||||||
|
conf.output_datefmt[BUFSIZ - 1] = '\0';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user