|
@@ -386,8 +386,13 @@ process_RegisterServer(UA_Server *server, UA_Session *session,
|
|
|
|
|
|
if(requestServer->semaphoreFilePath.length) {
|
|
|
#ifdef UA_ENABLE_DISCOVERY_SEMAPHORE
|
|
|
-
|
|
|
char* filePath = (char *)UA_malloc(sizeof(char)*requestServer->semaphoreFilePath.length+1);
|
|
|
+ if (!filePath) {
|
|
|
+ UA_LOG_ERROR_SESSION(server->config.logger, session,
|
|
|
+ "Cannot allocate memory for semaphore path. Out of memory.", NULL);
|
|
|
+ responseHeader->serviceResult = UA_STATUSCODE_BADOUTOFMEMORY;
|
|
|
+ return;
|
|
|
+ }
|
|
|
memcpy(filePath, requestServer->semaphoreFilePath.data, requestServer->semaphoreFilePath.length );
|
|
|
filePath[requestServer->semaphoreFilePath.length] = '\0';
|
|
|
if(access( filePath, 0 ) == -1) {
|
|
@@ -517,18 +522,22 @@ void UA_Discovery_cleanupTimedOut(UA_Server *server, UA_DateTime nowMonotonic) {
|
|
|
size_t fpSize = sizeof(char)*current->registeredServer.semaphoreFilePath.length+1;
|
|
|
|
|
|
char* filePath = (char *)UA_malloc(fpSize);
|
|
|
- memcpy(filePath, current->registeredServer.semaphoreFilePath.data,
|
|
|
- current->registeredServer.semaphoreFilePath.length );
|
|
|
- filePath[current->registeredServer.semaphoreFilePath.length] = '\0';
|
|
|
+ if (filePath) {
|
|
|
+ memcpy(filePath, current->registeredServer.semaphoreFilePath.data,
|
|
|
+ current->registeredServer.semaphoreFilePath.length );
|
|
|
+ filePath[current->registeredServer.semaphoreFilePath.length] = '\0';
|
|
|
#ifdef UNDER_CE
|
|
|
- FILE *fp = fopen(filePath,"rb");
|
|
|
- semaphoreDeleted = (fp==NULL);
|
|
|
- if(fp)
|
|
|
- fclose(fp);
|
|
|
+ FILE *fp = fopen(filePath,"rb");
|
|
|
+ semaphoreDeleted = (fp==NULL);
|
|
|
+ if(fp)
|
|
|
+ fclose(fp);
|
|
|
#else
|
|
|
- semaphoreDeleted = access( filePath, 0 ) == -1;
|
|
|
+ semaphoreDeleted = access( filePath, 0 ) == -1;
|
|
|
#endif
|
|
|
- UA_free(filePath);
|
|
|
+ UA_free(filePath);
|
|
|
+ } else {
|
|
|
+ UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER, "Cannot check registration semaphore. Out of memory");
|
|
|
+ }
|
|
|
}
|
|
|
#endif
|
|
|
|