diff --git a/CMakeLists.txt b/CMakeLists.txt index 42d4fc058..6f3594151 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,7 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) # overwritten with more detailed information if git is available. set(OPEN62541_VER_MAJOR 1) set(OPEN62541_VER_MINOR 4) -set(OPEN62541_VER_PATCH 3) +set(OPEN62541_VER_PATCH 4) set(OPEN62541_VER_LABEL "-undefined") # like "-rc1" or "-g4538abcd" or "-g4538abcd-dirty" set(OPEN62541_VER_COMMIT "unknown-commit") @@ -1013,7 +1013,7 @@ if(UA_NAMESPACE_ZERO STREQUAL "FULL") # Set the full Nodeset for NS0 if(NOT UA_FILE_NS0) - set(UA_FILE_NS0 ${UA_SCHEMA_DIR}/Opc.Ua.NodeSet2.xml) + set(UA_FILE_NS0 ${UA_SCHEMA_DIR}/Opc.Ua.NodeSet2.xml CACHE INTERNAL "") endif() # Check that the submodule was checked out or manually downloaded into the folder @@ -1032,7 +1032,7 @@ else() # Set the reduced Nodeset for NS0 if(NOT UA_FILE_NS0) - set(UA_FILE_NS0 ${UA_SCHEMA_DIR}/Opc.Ua.NodeSet2.Reduced.xml) + set(UA_FILE_NS0 ${UA_SCHEMA_DIR}/Opc.Ua.NodeSet2.Reduced.xml CACHE INTERNAL "") endif() # Set feature-specific datatypes definitions and nodesets diff --git a/deps/base64.c b/deps/base64.c index de30b0230..d2b9676f8 100644 --- a/deps/base64.c +++ b/deps/base64.c @@ -80,18 +80,27 @@ static unsigned char dtable[256] = { unsigned char * UA_unbase64(const unsigned char *src, size_t len, size_t *out_len) { - if(len == 0 || len % 4 != 0) + /* Empty base64 results in an empty byte-string */ + if(len == 0) { + *out_len = 0; + return (unsigned char*)UA_EMPTY_ARRAY_SENTINEL; + } + + /* The input length must be a multiple of four */ + if(len % 4 != 0) return NULL; - unsigned char *out, *pos; + /* Allocate the output string */ size_t olen = len / 4 * 3; - pos = out = (unsigned char*)UA_malloc(olen); + unsigned char *out = (unsigned char*)UA_malloc(olen); if(!out) return NULL; + /* Iterate over the input */ size_t pad = 0; unsigned char count = 0; unsigned char block[4]; + unsigned char *pos = out; for(size_t i = 0; i < len; i++) { unsigned char tmp = dtable[src[i]]; if(tmp == 0x80) @@ -103,9 +112,9 @@ UA_unbase64(const unsigned char *src, size_t len, size_t *out_len) { block[count] = tmp; count++; if(count == 4) { - *pos++ = (block[0] << 2) | (block[1] >> 4); - *pos++ = (block[1] << 4) | (block[2] >> 2); - *pos++ = (block[2] << 6) | block[3]; + *pos++ = (unsigned char)((block[0] << 2) | (block[1] >> 4)); + *pos++ = (unsigned char)((block[1] << 4) | (block[2] >> 2)); + *pos++ = (unsigned char)((block[2] << 6) | block[3]); if(pad) { if(pad == 1) pos--; diff --git a/src/pubsub/ua_pubsub.h b/src/pubsub/ua_pubsub.h index 352721d0d..7653770c1 100644 --- a/src/pubsub/ua_pubsub.h +++ b/src/pubsub/ua_pubsub.h @@ -25,7 +25,7 @@ #include "ua_pubsub_networkmessage.h" #ifdef UA_ENABLE_PUBSUB_SKS -#include +#include "ua_pubsub_keystorage.h" #endif /** diff --git a/src/ua_types_encoding_binary.c b/src/ua_types_encoding_binary.c index 1f72b7567..03e159603 100644 --- a/src/ua_types_encoding_binary.c +++ b/src/ua_types_encoding_binary.c @@ -1343,10 +1343,10 @@ FUNC_ENCODE_BINARY(DiagnosticInfo) { ret |= ENCODE_DIRECT(&src->symbolicId, UInt32); /* Int32 */ if(src->hasNamespaceUri) ret |= ENCODE_DIRECT(&src->namespaceUri, UInt32); /* Int32 */ - if(src->hasLocalizedText) - ret |= ENCODE_DIRECT(&src->localizedText, UInt32); /* Int32 */ if(src->hasLocale) ret |= ENCODE_DIRECT(&src->locale, UInt32); /* Int32 */ + if(src->hasLocalizedText) + ret |= ENCODE_DIRECT(&src->localizedText, UInt32); /* Int32 */ if(ret != UA_STATUSCODE_GOOD) return ret; @@ -1389,14 +1389,14 @@ FUNC_DECODE_BINARY(DiagnosticInfo) { dst->hasNamespaceUri = true; ret |= DECODE_DIRECT(&dst->namespaceUri, UInt32); /* Int32 */ } - if(encodingMask & 0x04u) { - dst->hasLocalizedText = true; - ret |= DECODE_DIRECT(&dst->localizedText, UInt32); /* Int32 */ - } if(encodingMask & 0x08u) { dst->hasLocale = true; ret |= DECODE_DIRECT(&dst->locale, UInt32); /* Int32 */ } + if(encodingMask & 0x04u) { + dst->hasLocalizedText = true; + ret |= DECODE_DIRECT(&dst->localizedText, UInt32); /* Int32 */ + } if(encodingMask & 0x10u) { dst->hasAdditionalInfo = true; ret |= DECODE_DIRECT(&dst->additionalInfo, String);