Skip to content

Conversation

@matth-x
Copy link
Contributor

@matth-x matth-x commented Aug 19, 2023

This PR fixes a crash which occurs for small input lengths of the base64_encode function.

For a very small auth (length < 3), the base64_encode function fails when reaching the following line:

https://github.com/Links2004/arduinoWebSockets/blob/751cf87b6cd684c9d339f0314a18b0ee866d449c/src/WebSockets.cpp#L582C22-L582C22

This is the error message on the console:

CORRUPT HEAP: Bad tail at 0x3ffbdb1c. Expected 0xbaad5678 got 0xbaad5600 assert failed: multi_heap_free multi_heap_poisoning.c:253 (head != NULL) 

Probably it is due to a buffer overflow. With a minimum buffer size of 5, this crash doesn't occur anymore.

To test the fix, I called WebSocketsClient::setAuthorization(const char * user, const char * password) with user "" and password "b".

Btw. and thanks for providing this library. I've been using it for years now and always enjoyed working with it.

@Links2004 Links2004 merged commit 30d5e13 into Links2004:master Aug 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants