Skip to content

Fix crashes caused by http authentication #1794

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

Closed
wants to merge 1 commit into from
Closed

Fix crashes caused by http authentication #1794

wants to merge 1 commit into from

Conversation

kzyapkov
Copy link
Contributor

I have a sketch which consistently crashes when correct HTTP credentials are provided in the Authorization header. Experiments showed that the crashes are caused by the delete[] statements for toencode and encoded. I wasn't able to decipher the core dumps.

Trial-and-error lead to the solution here. I have no explanation why it works, but definitely fixes the world for me.

@igrr
Copy link
Member

igrr commented Mar 18, 2016

I'd advise against use of VLA. Since we don't have a way to reliably catch stack overflow issues, there is no way to make sure variable-length stack allocation succeeds (and crash if it fails). So it's better to use either static fixed-length arrays or dynamically allocated arrays. I think to fix the issue it is sufficient to change +1 with +2 in toencodelen calculation.

Edit: or, rather, to maintain code style, add +1 in toencode declaration:

char *toencode = new char[toencodeLen + 1];

@igrr
Copy link
Member

igrr commented Mar 18, 2016

#1790 (comment)

@kzyapkov
Copy link
Contributor Author

Okay!

@kzyapkov kzyapkov closed this Mar 18, 2016
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

Successfully merging this pull request may close these issues.

2 participants