Skip to content

Commit

Permalink
tasofro: allocate more space for char_select spellcards, and print
Browse files Browse the repository at this point in the history
warnings in the logs when the buffers are too smalls.
  • Loading branch information
brliron committed Jul 4, 2017
1 parent 9a7d29f commit 879a9b5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions thcrap_tasofro/src/csv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ int patch_csv(char *file_inout, size_t size_out, size_t size_in, json_t *patch)
col = 0;
}
}
if (j > size_out) {
log_print("WARNING: buffer overflow in tasofro CSV patching (output buffer too small)!\n");
}

#ifdef _DEBUG
FILE* fd = fopen("out.csv", "wb");
Expand Down
2 changes: 1 addition & 1 deletion thcrap_tasofro/src/spellcards_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ json_t* spell_char_select_generator(std::unordered_map<std::string, json_t*> in_
return NULL;
}

*out_size = json_string_length(spell_translation);
*out_size = json_string_length(spell_translation) * 2; // Escaped characters take more place
json_t *ret = json_pack("{s{ss}}", "0", "5", json_string_value(spell_translation));
json_decref(spell_translation);
return ret;
Expand Down
3 changes: 3 additions & 0 deletions thcrap_tasofro/src/tfcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ int patch_tfcs(void *file_inout, size_t size_out, size_t size_in, json_t *patch)
size_out -= sizeof(header);
int ret = deflate_bytes(file_out_uncomp, file_out_uncomp_size, header->data, &size_out);
header->comp_size = size_out;
if (ret != Z_OK) {
log_printf("WARNING: tasofro CSV patching: compression failed with zlib error %d\n", ret);
}

HeapFree(GetProcessHeap(), 0, file_in_uncomp);
HeapFree(GetProcessHeap(), 0, file_out_uncomp);
Expand Down

0 comments on commit 879a9b5

Please sign in to comment.