diff --git a/src/elogd.c b/src/elogd.c index 1b88f16d..5d9471e1 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -4500,7 +4500,7 @@ int el_retrieve(LOGBOOK * lbs, int message_id, char *date, char attr_list[MAX_N_ if (index == *lbs->n_el_index) return EL_NO_MSG; - sprintf(file_name, "%s%s%s", lbs->data_dir, lbs->el_index[index].subdir, lbs->el_index[index].file_name); + snprintf(file_name, sizeof(file_name), "%s%s%s", lbs->data_dir, lbs->el_index[index].subdir, lbs->el_index[index].file_name); fh = open(file_name, O_RDONLY | O_BINARY, 0644); if (fh < 0) { /* file might have been deleted, rebuild index */ @@ -4761,7 +4761,7 @@ int el_retrieve_attachment(LOGBOOK * lbs, int message_id, int n, char name[MAX_P if (index == *lbs->n_el_index) return EL_NO_MSG; - sprintf(file_name, "%s%s%s", lbs->data_dir, lbs->el_index[index].subdir, lbs->el_index[index].file_name); + snprintf(file_name, sizeof(file_name), "%s%s%s", lbs->data_dir, lbs->el_index[index].subdir, lbs->el_index[index].file_name); fh = open(file_name, O_RDONLY | O_BINARY, 0644); if (fh < 0) { /* file might have been deleted, rebuild index */ @@ -4891,7 +4891,7 @@ int el_submit(LOGBOOK * lbs, int message_id, BOOL bedit, char *date, char attr_n return -1; } - sprintf(file_name, "%s%s%s", lbs->data_dir, lbs->el_index[index].subdir, lbs->el_index[index].file_name); + snprintf(file_name, sizeof(file_name), "%s%s%s", lbs->data_dir, lbs->el_index[index].subdir, lbs->el_index[index].file_name); fh = open(file_name, O_CREAT | O_RDWR | O_BINARY, 0644); if (fh < 0) { xfree(message); @@ -4993,7 +4993,7 @@ int el_submit(LOGBOOK * lbs, int message_id, BOOL bedit, char *date, char attr_n if (strncmp(date1 + 8, mname[i], 3) == 0) break; - sprintf(file_name, "%c%c%02d%c%ca.log", date1[14], date1[15], i + 1, date1[5], date1[6]); + snprintf(file_name, sizeof(file_name), "%c%c%02d%c%ca.log", date1[14], date1[15], i + 1, date1[5], date1[6]); generate_subdir_name(file_name, subdir, sizeof(subdir)); sprintf(str, "%s%s", dir, subdir); @@ -5239,7 +5239,7 @@ int el_delete_message(LOGBOOK * lbs, int message_id, BOOL delete_attachments, if (index == *lbs->n_el_index) return -1; - sprintf(file_name, "%s%s%s", lbs->data_dir, lbs->el_index[index].subdir, lbs->el_index[index].file_name); + snprintf(file_name, sizeof(file_name), "%s%s%s", lbs->data_dir, lbs->el_index[index].subdir, lbs->el_index[index].file_name); fh = open(file_name, O_RDWR | O_BINARY, 0644); if (fh < 0) return EL_FILE_ERROR; @@ -6613,9 +6613,9 @@ void rsputs_elcode(LOGBOOK * lbs, BOOL email_notify, const char *str) strstr(pattern_list[l].subst, "img") == NULL && strncmp(pattern_list[l].subst, "name_enc); + snprintf(str, sizeof(str), "../%s/", lbs->name_enc); else if (getcfg_topgroup()) sprintf(str, "."); } @@ -7447,7 +7447,7 @@ int scan_attributes(char *logbook) strieq(attr_list[i], "reply to") || strieq(attr_list[i], "locked by") || strieq(attr_list[i], "in reply to") || strieq(attr_list[i], "attachment")) { - sprintf(str, loc("Attribute \"%s\" is not allowed in config file"), attr_list[i]); + snprintf(str, sizeof(str), loc("Attribute \"%s\" is not allowed in config file"), attr_list[i]); show_error(str); return -1; } @@ -7458,29 +7458,29 @@ int scan_attributes(char *logbook) for (i = 0; i < n; i++) { n_options = 0; - sprintf(str, "Options %s", attr_list[i]); + snprintf(str, sizeof(str), "Options %s", attr_list[i]); if (getcfg(logbook, str, list, sizeof(list))) n_options = strbreak(list, attr_options[i], MAX_N_LIST, ",", FALSE); - sprintf(str, "MOptions %s", attr_list[i]); + snprintf(str, sizeof(str), "MOptions %s", attr_list[i]); if (getcfg(logbook, str, list, sizeof(list))) { n_options = strbreak(list, attr_options[i], MAX_N_LIST, ",", FALSE); attr_flags[i] |= AF_MULTI; } - sprintf(str, "ROptions %s", attr_list[i]); + snprintf(str, sizeof(str), "ROptions %s", attr_list[i]); if (getcfg(logbook, str, list, sizeof(list))) { n_options = strbreak(list, attr_options[i], MAX_N_LIST, ",", FALSE); attr_flags[i] |= AF_RADIO; } - sprintf(str, "IOptions %s", attr_list[i]); + snprintf(str, sizeof(str), "IOptions %s", attr_list[i]); if (getcfg(logbook, str, list, sizeof(list))) { n_options = strbreak(list, attr_options[i], MAX_N_LIST, ",", FALSE); attr_flags[i] |= AF_ICON; } - sprintf(str2, "Sort Attribute Options %s", attr_list[i]); + snprintf(str2, sizeof(str2), "Sort Attribute Options %s", attr_list[i]); if (n_options && getcfg(logbook, str2, str, sizeof(str)) && atoi(str) == 1) { qsort(attr_options[i], n_options, NAME_LENGTH, ascii_compare2); } @@ -7532,7 +7532,7 @@ int scan_attributes(char *logbook) } for (i = 0; i < n; i++) { - sprintf(str, "Type %s", attr_list[i]); + snprintf(str, sizeof(str), "Type %s", attr_list[i]); if (getcfg(logbook, str, type, sizeof(type))) { if (strieq(type, "date")) attr_flags[i] |= AF_DATE; @@ -14783,7 +14783,7 @@ int show_download_page(LOGBOOK * lbs, char *path) if (index == *lbs->n_el_index) return EL_NO_MSG; - sprintf(file_name, "%s%s%s", lbs->data_dir, lbs->el_index[index].subdir, lbs->el_index[index].file_name); + snprintf(file_name, sizeof(file_name), "%s%s%s", lbs->data_dir, lbs->el_index[index].subdir, lbs->el_index[index].file_name); fh = open(file_name, O_RDWR | O_BINARY, 0644); if (fh < 0) return EL_FILE_ERROR;