Skip to content

Commit

Permalink
fix a oss-fuzz issue for writing with ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
jpfr committed Jan 16, 2018
1 parent 84a8d02 commit 25dd900
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/server/ua_services_attribute.c
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,12 @@ writeValueAttributeWithRange(UA_VariableNode *node, const UA_DataValue *value,
v = &editableValue;
}

/* Check that the type is an exact match and not only "compatible" */
if(!node->value.data.value.value.type ||
!UA_NodeId_equal(&node->value.data.value.value.type->typeId,
&v->type->typeId))
return UA_STATUSCODE_BADTYPEMISMATCH;

/* Write the value */
UA_StatusCode retval = UA_Variant_setRangeCopy(&node->value.data.value.value,
v->data, v->arrayLength, *rangeptr);
Expand Down Expand Up @@ -959,10 +965,10 @@ writeValueAttribute(UA_Server *server, UA_Session *session,
if(value->hasValue && value->value.type) {
adjustValue(server, &adjustedValue.value, &node->dataType);

/* The value may be an extension object, especially the nodeset compiler uses
* extension objects to write variable values.
* If value is an extension object we check if the current node value is also an extension object.
*/
/* The value may be an extension object, especially the nodeset compiler
* uses extension objects to write variable values. If value is an
* extension object we check if the current node value is also an
* extension object. */
UA_Boolean compatible;
if (value->value.type->typeId.identifierType == UA_NODEIDTYPE_NUMERIC &&
value->value.type->typeId.identifier.numeric == UA_NS0ID_STRUCTURE) {
Expand Down

0 comments on commit 25dd900

Please sign in to comment.