Explorar el Código

Fix undefined behavior

Mark Giraud hace 6 años
padre
commit
91f54454d1
Se han modificado 1 ficheros con 2 adiciones y 1 borrados
  1. 2 1
      src/server/ua_services_discovery_multicast.c

+ 2 - 1
src/server/ua_services_discovery_multicast.c

@@ -418,7 +418,8 @@ UA_Discovery_addRecord(UA_Server *server, const UA_String *servername,
     // TXT record: [servername]-[hostname]._opcua-tcp._tcp.local. TXT path=/ caps=NA,DA,...
     UA_STACKARRAY(char, pathChars, path->length + 1);
     if(createTxt) {
-        memcpy(pathChars, path->data, path->length);
+        if(path->length > 0)
+            memcpy(pathChars, path->data, path->length);
         pathChars[path->length] = 0;
         mdns_create_txt(server, fullServiceDomain, pathChars, capabilites,
                         capabilitiesSize, UA_Discovery_multicastConflict);