Skip to content

Commit bcfa5c8

Browse files
committed
Merge pull request esp8266#1336 from BuzzBurrowes/master
Fixed crash bug with mDNS
2 parents dff0700 + 73f80c5 commit bcfa5c8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

libraries/ESP8266mDNS/ESP8266mDNS.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ void MDNSResponder::_parsePacket(){
290290
uint16_t servicePort = 0;
291291

292292
char protoName[32];
293-
uint8_t protoNameLen;
293+
protoName[0] = 0;
294+
uint8_t protoNameLen = 0;
294295

295296
uint16_t packetHeader[6];
296297

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

332333
if(serviceName[0] == '_'){
333-
memcpy(serviceName, serviceName+1, serviceNameLen);
334+
memmove(serviceName, serviceName+1, serviceNameLen);
334335
serviceNameLen--;
335336
serviceParsed = true;
336337
} else if(serviceNameLen == 5 && strcmp("local", serviceName) == 0){
@@ -362,7 +363,7 @@ void MDNSResponder::_parsePacket(){
362363
_conn_readS(protoName, protoNameLen);
363364
protoName[protoNameLen] = '\0';
364365
if(protoNameLen == 4 && protoName[0] == '_'){
365-
memcpy(protoName, protoName+1, protoNameLen);
366+
memmove(protoName, protoName+1, protoNameLen);
366367
protoNameLen--;
367368
protoParsed = true;
368369
} else {
@@ -494,7 +495,7 @@ void MDNSResponder::_reply(uint8_t replyMask, char * service, char *proto, uint1
494495
size_t hostNameLen = hostName.length();
495496

496497
char underscore[] = "_";
497-
498+
498499
// build service name with _
499500
char serviceName[os_strlen(service)+2];
500501
os_strcpy(serviceName,underscore);

0 commit comments

Comments
 (0)