Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BitcoinResult Bitcoin_FixBase58Check() fn signature, implementation, call mismatch ? #27

Open
pulmark opened this issue Dec 12, 2017 · 0 comments

Comments

@pulmark
Copy link

pulmark commented Dec 12, 2017

base58.h file contains the function signature as follows:

BitcoinResult Bitcoin_FixBase58Check(
char *fixed_output, size_t fixed_output_buffer_size,
size_t *fixed_output_size, uint8_t *output, size_t output_buffer_size,
size_t *decoded_output_size, const char *input, size_t input_size,
unsigned change_chars, unsigned insert_chars, unsigned remove_chars);

The implementation is in file base58.c and the naming or order of last two parameters are different.

BitcoinResult Bitcoin_FixBase58Check(
char *fixed_output, size_t fixed_output_buffer_size, size_t *fixed_output_size,
uint8_t *output, size_t output_buffer_size, size_t *decoded_output_size,
const char *input, size_t input_size,
unsigned change_chars,
unsigned remove_chars,
unsigned insert_chars)
{
}

Function is called from main.c and there the naming of last two parameters follows the signature.

				result = Bitcoin_FixBase58Check(
					output_base58, output_base58_buffer_size, &output_base58_size,
					self->input_raw, sizeof(self->input_raw), &self->input_raw_size,
					self->input, self->input_size,
					self->options.fix_base58_change_chars,
					self->options.fix_base58_insert_chars,
					self->options.fix_base58_remove_chars)

My understanding is that when running the code the fix_base58_insert_chars and fix_base58_remove_chars might not be used properly. Compiler complains about the implementation that remove_chars is not used. So when calling the function, ...insert_chars are not used and ... remove_chars are used as insert_chars ?

Noticed the issue when trying to get rid of compiler warnings in my forked revision. I haven't dig deep into the code. I just build a simple wrapper for tool so that it can be used as library from my code. I have pushed my changes into fork that can be found at:

https://github.com/pulmark/bitcoin-tool

Using the tool as library works when called via wrapper. I redirected the results back to my app by using a simple callback also. The implementation details are in .lib directory in my fork.

I will push my app into github later this year or in the beginning of next year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant