fix converting authorization key to hex string #12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
In the AuthKey raw-to-hex conversion loop, the loop variable was incremented by 2 (
i += 2
) which skipped every second byte inauth_key_factory
. In addition, thesnprintf(auth_key_hex + 2 * i, ...)
wrote to index 4 in the second loop execution, while the first loop execution wrote a\0
to index 2, thus the variableauth_key_hex
always contained only 2 characters (plus zero-termination). So in the end, only the first byte ofauth_key_factory
was stored, the rest was completely lost.I found this because the authentication didn't work for me. Changing
i += 2
toi++
fixed the problem. The same problem existed insetAuthKey()
. Note that there was already a place where the conversion was correct:MicroOcppMongoose/src/MicroOcppMongooseClient.cpp
Lines 202 to 211 in 95f4748
Just let me know if I need to adjust anything.