From: Kevin Day Date: Sat, 11 Dec 2021 20:54:11 +0000 (-0600) Subject: Bugfix: Failed to produce identical binary when passing appropriate parameters. X-Git-Tag: 0.5.7~48 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=476bc6974555b789db1c4ed1344976748da69213;p=fll Bugfix: Failed to produce identical binary when passing appropriate parameters. Taking a binary input with a binary output while passing +nq should result in a byte-for-byte duplicate binary. Example: "utf8 -f /bin/bash -bB +nq -F /tmp/bash". This is failing for two reasons: 1) Not using the original string data when printing detected invalid characters. 2) Performing the from codepoint check before checking the binary output check in the function utf8_print_character(). Also remove a redundant not zero check in the error print function utf8_print_character_invalid(). the function utf8_print_character_invalid() is a wrapper to utf8_print_character(), where that check is already performed. --- diff --git a/level_3/utf8/c/private-print.c b/level_3/utf8/c/private-print.c index 8e87d65..f362bf6 100644 --- a/level_3/utf8/c/private-print.c +++ b/level_3/utf8/c/private-print.c @@ -18,12 +18,12 @@ extern "C" { if (!character.used) return; - if (data->mode & utf8_mode_from_codepoint_d) { - fl_print_format("%s%[%Q%]%s", data->file.stream, data->prepend, set, character, set, data->append); - } - else if (data->mode & utf8_mode_to_binary_d) { + if (data->mode & utf8_mode_to_binary_d) { fl_print_format("%s%[%r%]%s", data->file.stream, data->prepend, set, character, set, data->append); } + else if (data->mode & utf8_mode_from_codepoint_d) { + fl_print_format("%s%[%Q%]%s", data->file.stream, data->prepend, set, character, set, data->append); + } else { fl_print_format("%s%[0x", data->file.stream, data->prepend, set); @@ -39,7 +39,6 @@ extern "C" { #ifndef _di_utf8_print_character_invalid_ void utf8_print_character_invalid(utf8_data_t * const data, const f_string_static_t character) { - if (!character.used) return; if (data->main->parameters[utf8_parameter_strip_invalid].result == f_console_result_found) return; if (data->main->parameters[utf8_parameter_verify].result == f_console_result_found) return; diff --git a/level_3/utf8/c/private-utf8_binary.c b/level_3/utf8/c/private-utf8_binary.c index 2a387b1..26e5edb 100644 --- a/level_3/utf8/c/private-utf8_binary.c +++ b/level_3/utf8/c/private-utf8_binary.c @@ -30,7 +30,7 @@ extern "C" { if (status == F_failure || status == F_utf || status == F_utf_fragment || status == F_valid_not) { valid_not = F_true; - utf8_print_character_invalid(data, data->text); + utf8_print_character_invalid(data, character); } else { status = F_status_set_error(status); diff --git a/level_3/utf8/c/private-utf8_codepoint.c b/level_3/utf8/c/private-utf8_codepoint.c index fbe9fe4..601bc57 100644 --- a/level_3/utf8/c/private-utf8_codepoint.c +++ b/level_3/utf8/c/private-utf8_codepoint.c @@ -41,7 +41,7 @@ extern "C" { if (status == F_failure || status == F_utf || status == F_utf_fragment || status == F_valid_not) { valid_not = F_true; - utf8_print_character_invalid(data, data->text); + utf8_print_character_invalid(data, character); } else { status = F_status_set_error(status); @@ -76,7 +76,7 @@ extern "C" { else { status = F_none; - utf8_print_character_invalid(data, data->text); + utf8_print_character_invalid(data, character); } *mode = utf8_codepoint_mode_ready;