Browse Source

Set minimum random node ID to 50000.

Previously there may have happened a node ID collission:
While adding a full nodeset (e.g. ADI) it creates child nodes
with random IDs. This random child ID may collide with a predefined
node ID in the nodeset which will be added later.
Stefan Profanter 6 years ago
parent
commit
cf21ac33dd
1 changed files with 5 additions and 2 deletions
  1. 5 2
      plugins/ua_nodestore_default.c

+ 5 - 2
plugins/ua_nodestore_default.c

@@ -330,9 +330,12 @@ UA_NodeMap_insertNode(void *context, UA_Node *node,
     if(tempNodeid.identifierType == UA_NODEIDTYPE_NUMERIC &&
        tempNodeid.identifier.numeric == 0) {
         /* create a random nodeid */
-        UA_UInt32 identifier = ns->count+1; // start value
+		/* start at least with 50,000 to make sure we don not conflict with nodes from the spec */
+		/* E.g. adding a nodeset will create children while there are still other nodes which need to be created */
+		/* Thus the node id's may collide */
+        UA_UInt32 identifier = 50000 + ns->count+1; // start value
         UA_UInt32 size = ns->size;
-        UA_UInt32 increase = mod2(identifier, size);
+        UA_UInt32 increase = mod2(ns->count+1, size);
         while(true) {
             node->nodeId.identifier.numeric = identifier;
             slot = findFreeSlot(ns, &node->nodeId);