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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions libraries/ESP8266mDNS/ESP8266mDNS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ void MDNSResponder::_parsePacket(){
uint16_t servicePort = 0;

char protoName[32];
uint8_t protoNameLen;
protoName[0] = 0;
uint8_t protoNameLen = 0;

uint16_t packetHeader[6];

Expand Down Expand Up @@ -330,7 +331,7 @@ void MDNSResponder::_parsePacket(){
serviceName[serviceNameLen] = '\0';

if(serviceName[0] == '_'){
memcpy(serviceName, serviceName+1, serviceNameLen);
memmove(serviceName, serviceName+1, serviceNameLen);
serviceNameLen--;
serviceParsed = true;
} else if(serviceNameLen == 5 && strcmp("local", serviceName) == 0){
Expand Down Expand Up @@ -362,7 +363,7 @@ void MDNSResponder::_parsePacket(){
_conn_readS(protoName, protoNameLen);
protoName[protoNameLen] = '\0';
if(protoNameLen == 4 && protoName[0] == '_'){
memcpy(protoName, protoName+1, protoNameLen);
memmove(protoName, protoName+1, protoNameLen);
protoNameLen--;
protoParsed = true;
} else {
Expand Down Expand Up @@ -494,7 +495,7 @@ void MDNSResponder::_reply(uint8_t replyMask, char * service, char *proto, uint1
size_t hostNameLen = hostName.length();

char underscore[] = "_";

// build service name with _
char serviceName[os_strlen(service)+2];
os_strcpy(serviceName,underscore);
Expand Down