Skip to content

Fixed crash bug with mDNS #1336

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

Merged
merged 4 commits into from
Jan 2, 2016
Merged

Fixed crash bug with mDNS #1336

merged 4 commits into from
Jan 2, 2016

Conversation

BuzzBurrowes
Copy link
Contributor

The character buffer protoName, created on the stack in the function MDNSResponder::_parsePacket(), is uninitialized. It can remain uninitialized all the way to the bottom of that function, where it is passed to the function MDNSResponder::_reply.

In MDNSResponder::_reply, the pointer passed in is named 'proto'. You will will find these lines of code near the top of that function...

//build proto name with _
char protoName[5];
os_strcpy(protoName,underscore);
os_strcat(protoName, proto);
size_t protoNameLen = 4; 

You can see there that if proto points to an uninitialized character buffer on the stack, the strcat call can blow way the stack.

I was getting random crashes when a client tried to connect to my esp8266 server using the 'server.local' host name. Those crashes have disappeared since I made this change.

Oh... one more thing... I changed a few memcpy to memmove calls where the source and destination overlap. Not sure that was causing a problem, but I believe memcpy does not guarantee correct results if the source and destination overlap.

@BuzzBurrowes
Copy link
Contributor Author

This continuous build failure looks unrelated to my change.

@Links2004
Copy link
Collaborator

yes build server has failed, make a empty commit or merge again from master if possible.

@BuzzBurrowes
Copy link
Contributor Author

Done

Links2004 added a commit that referenced this pull request Jan 2, 2016
@Links2004 Links2004 merged commit bcfa5c8 into esp8266:master Jan 2, 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