Skip to content

Commit

Permalink
Merge pull request #1336 from BuzzBurrowes/master
Browse files Browse the repository at this point in the history
Fixed crash bug with mDNS
  • Loading branch information
Links2004 committed Jan 2, 2016
2 parents dff0700 + 73f80c5 commit bcfa5c8
Showing 1 changed file with 5 additions and 4 deletions.
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

0 comments on commit bcfa5c8

Please sign in to comment.