commit 97b50cc235590672db96338ca8d4367137d39895
parent 07d5252f543e8518d3863b3dccd3a5415cbd1032
Author: Andreas Gruhler <agruhl@gmx.ch>
Date: Sun, 19 Jun 2022 23:55:19 +0200
fix wrong arg type and limit char scans
Diffstat:
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/diary.c b/src/diary.c
@@ -314,7 +314,7 @@ bool read_config(const char* file_path) {
// ignore comment lines
if (*line == '#' || *line == ';') continue;
- if (sscanf(line, "%s = %s", key_buf, value_buf) == 2) {
+ if (sscanf(line, "%256s = %256s", key_buf, value_buf) == 2) {
if (strcmp("dir", key_buf) == 0) {
expaned_value = expand_path(value_buf);
CONFIG.dir = (char *) malloc(strlen(expaned_value) + 1 * sizeof(char));
@@ -588,7 +588,7 @@ int main(int argc, char** argv) {
int ch = 0, conf_ch = 0;
int pad_pos = 0;
int syear = 0, smonth = 0, sday = 0;
- char ics_filepath[256];
+ char ics_filepath;
char* expanded_ics_filepath;
struct tm new_date;
int prev_width = COLS - ASIDE_WIDTH - CAL_WIDTH;
@@ -877,8 +877,8 @@ int main(int argc, char** argv) {
wclear(header);
curs_set(2);
mvwprintw(header, 0, 0, "Import from file: ");
- if (wscanw(header, "%s", &ics_filepath) == 1) {
- expanded_ics_filepath = expand_path(ics_filepath);
+ if (wscanw(header, "%256s", &ics_filepath) == 1) {
+ expanded_ics_filepath = expand_path(&ics_filepath);
ics_import(expanded_ics_filepath, header, cal, aside, &pad_pos, &curs_date, &cal_start, &cal_end);
free(expanded_ics_filepath);
}
@@ -891,8 +891,8 @@ int main(int argc, char** argv) {
wclear(header);
curs_set(2);
mvwprintw(header, 0, 0, "Export to file: ");
- if (wscanw(header, "%s", &ics_filepath) == 1) {
- expanded_ics_filepath = expand_path(ics_filepath);
+ if (wscanw(header, "%256s", &ics_filepath) == 1) {
+ expanded_ics_filepath = expand_path(&ics_filepath);
ics_export(expanded_ics_filepath, header, cal, aside, &pad_pos, &curs_date, &cal_start, &cal_end);
free(expanded_ics_filepath);
}