Browse Source

Merge remote-tracking branch '1.0' into master

Stefan Profanter 5 years ago
parent
commit
70bcb86b19

+ 3 - 1
debian/rules-template

@@ -3,7 +3,6 @@
 export DH_VERBOSE = 1
 
 export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-pie
-export DEB_BUILD_OPTIONS=parallel=4
 
 override_dh_auto_configure:
 	dh_auto_configure -- -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUA_NAMESPACE_ZERO=FULL -DUA_ENABLE_AMALGAMATION=OFF -DUA_PACK_DEBIAN=ON
@@ -11,5 +10,8 @@ override_dh_auto_configure:
 override_dh_auto_test:
 	dh_auto_test -- ARGS+=--output-on-failure
 
+override_dh_auto_build:
+	dh_auto_build -- -j`nproc --ignore=2`
+
 %:
 	dh $@ --buildsystem=cmake --parallel

+ 15 - 4
deps/itoa.c

@@ -69,12 +69,23 @@ UA_UInt16 itoaUnsigned(UA_UInt64 value, char* buffer, UA_Byte base) {
 /* adapted from http://www.techiedelight.com/implement-itoa-function-in-c/ to use UA_... types */
 UA_UInt16 itoaSigned(UA_Int64 value, char* buffer) {
     /* consider absolute value of number */
-    UA_UInt64 n = (UA_UInt64)value;
 
-    if(value < 0){
-        n = (UA_UInt64)-value;
+
+    UA_UInt64 n;
+
+    /* Special case for UA_INT64_MIN which can not simply be negated */
+    /* it will cause a signed integer overflow */
+    if (value == UA_INT64_MIN) {
+        n = (UA_UInt64)UA_INT64_MAX + 1;
     }
-    
+    else {
+        n = (UA_UInt64)value;
+
+        if(value < 0){
+            n = (UA_UInt64)-value;
+        }
+    }
+
     UA_UInt16 i = 0;
     while (n) {
         UA_UInt64 r = n % 10;

+ 3 - 3
include/open62541/types.h

@@ -104,8 +104,8 @@ typedef uint32_t UA_UInt32;
  * An integer value between -9 223 372 036 854 775 808 and
  * 9 223 372 036 854 775 807. */
 typedef int64_t UA_Int64;
-#define UA_INT64_MIN ((int64_t)-9223372036854775808)
-#define UA_INT64_MAX (int64_t)9223372036854775807
+#define UA_INT64_MAX (int64_t)9223372036854775807LL
+#define UA_INT64_MIN ((int64_t)-UA_INT64_MAX-1LL)
 
 /**
  * UInt64
@@ -113,7 +113,7 @@ typedef int64_t UA_Int64;
  * An integer value between 0 and 18 446 744 073 709 551 615. */
 typedef uint64_t UA_UInt64;
 #define UA_UINT64_MIN (uint64_t)0
-#define UA_UINT64_MAX (uint64_t)18446744073709551615
+#define UA_UINT64_MAX (uint64_t)18446744073709551615ULL
 
 /**
  * Float

+ 2 - 1
src/server/ua_subscription_events.c

@@ -13,7 +13,8 @@
 UA_StatusCode
 UA_MonitoredItem_removeNodeEventCallback(UA_Server *server, UA_Session *session,
                                          UA_Node *node, void *data) {
-    UA_assert(node->nodeClass == UA_NODECLASS_OBJECT);
+    if (node->nodeClass != UA_NODECLASS_OBJECT)
+        return UA_STATUSCODE_BADINVALIDARGUMENT;
     UA_ObjectNode *on = (UA_ObjectNode*)node;
     UA_MonitoredItem *remove = (UA_MonitoredItem*)data;
 

+ 5 - 2
src/ua_types_encoding_json.c

@@ -2622,8 +2622,8 @@ DECODE_JSON(Variant) {
         return UA_STATUSCODE_GOOD;
     }
 
-    size_t size = (size_t)(parseCtx->tokenArray[searchResultType].end -
-                           parseCtx->tokenArray[searchResultType].start);
+    size_t size = ((size_t)parseCtx->tokenArray[searchResultType].end -
+                   (size_t)parseCtx->tokenArray[searchResultType].start);
 
     /* check if size is zero or the type is not a number */
     if(size < 1 || parseCtx->tokenArray[searchResultType].type != JSMN_PRIMITIVE)
@@ -2946,6 +2946,9 @@ Variant_decodeJsonUnwrapExtensionObject(UA_Variant *dst, const UA_DataType *type
     if(encoding == 0 || typeOfBody != NULL) {
         /*This value is 0 if the body is Structure encoded as a JSON object (see 5.4.6).*/
         /* Found a valid type and it is structure encoded so it can be unwrapped */
+        if (typeOfBody == NULL)
+            return UA_STATUSCODE_BADDECODINGERROR;
+
         dst->type = typeOfBody;
 
         /* Allocate memory for type*/