diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-09-12 14:51:41 +0200 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-09-12 14:51:41 +0200 |
| commit | d174d803de2296061731c3698980a6a51e6fc3ef (patch) | |
| tree | 27cf4a1d2e5c8d7ec98b3c88641d2fc4e231543d /src/administration_writer.cpp | |
| parent | 12f306e2144081e00c36ed9942068462604bef55 (diff) | |
fix invoice savefile overflow
Diffstat (limited to 'src/administration_writer.cpp')
| -rw-r--r-- | src/administration_writer.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/administration_writer.cpp b/src/administration_writer.cpp index d9c9c31..c97a828 100644 --- a/src/administration_writer.cpp +++ b/src/administration_writer.cpp @@ -5,6 +5,7 @@ #include <stdlib.h> #include <threads.h> +#include "log.hpp" #include "ui.hpp" #include "strops.hpp" #include "administration_writer.hpp" @@ -170,7 +171,7 @@ static char* administration_writer_get_eas_scheme_for_address(address addr) bool administration_writer_save_invoice_blocking(invoice inv) { bool result = 1; - int buf_length = 15000; // Ballpark file content size. + int buf_length = 150000; // Ballpark file content size. char* file_content = (char*)malloc(buf_length); memset(file_content, 0, buf_length); memcpy(file_content, peppol_invoice_template, strlen(peppol_invoice_template)); @@ -218,6 +219,7 @@ bool administration_writer_save_invoice_blocking(invoice inv) u32 tax_subtotal_list_buffer_size = (u32)strlen(peppol_invoice_tax_subtotal_template) * 2 * tax_bracket_count; // Ballpark list size. char* tax_subtotal_list_buffer = (char*)malloc(tax_subtotal_list_buffer_size); + memset(tax_subtotal_list_buffer, 0, tax_subtotal_list_buffer_size); u32 tax_subtotal_list_buffer_cursor = 0; for (u32 i = 0; i < tax_bracket_count; i++) @@ -260,6 +262,7 @@ bool administration_writer_save_invoice_blocking(invoice inv) u32 billing_item_list_buffer_size = (u32)strlen(peppol_invoice_line_template) * 2 * billing_item_count; // Ballpark list size. char* billing_item_list_buffer = (char*)malloc(billing_item_list_buffer_size); + memset(billing_item_list_buffer, 0, billing_item_list_buffer_size); u32 billing_item_list_buffer_cursor = 0; for (u32 i = 0; i < billing_item_count; i++) @@ -304,11 +307,13 @@ bool administration_writer_save_invoice_blocking(invoice inv) snprintf(final_path, 50, "%s.xml", inv.id); int final_length = (int)strlen(file_content); - printf(file_content); if (!xml_parse_document((uint8_t*)file_content, final_length)) result = 0; else if (!administration_writer_write_to_zip(final_path, file_content, final_length)) result = 0; free(file_content); + + log_add(ImGui::GetTime(), "Saved file."); + return result; } |
