Browse Source

Fix memory leak

OSS-Fuzz issue: 3098

Credit to OSS-Fuzz
Stefan Profanter 7 years ago
parent
commit
f67569455b
2 changed files with 3 additions and 2 deletions
  1. 1 0
      src/server/ua_server_binary.c
  2. 2 2
      tests/fuzz/CMakeLists.txt

+ 1 - 0
src/server/ua_server_binary.c

@@ -328,6 +328,7 @@ processOPN(UA_Server *server, UA_Connection *connection,
     UA_SecureChannel *channel = connection->channel;
     if(!channel) {
         UA_OpenSecureChannelResponse_deleteMembers(&p);
+        UA_NodeId_deleteMembers(&requestType);
         UA_AsymmetricAlgorithmSecurityHeader_deleteMembers(&asymHeader);
         UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_NETWORK,
                     "Connection %i | Could not open a SecureChannel. "

+ 2 - 2
tests/fuzz/CMakeLists.txt

@@ -17,8 +17,8 @@ if (NOT UA_BUILD_OSS_FUZZ)
 
     # oss-fuzz builds already include these flags
     if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
-        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
-        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
+        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O1 -fsanitize=address")
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1 -fsanitize=address")
     else()
         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize-address-use-after-scope -fsanitize-coverage=trace-pc-guard,trace-cmp")
         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize-address-use-after-scope -fsanitize-coverage=trace-pc-guard,trace-cmp")