Bladeren bron

remove max_array. no longer needed since we use size_t everywhere and decoding checks if the message permits the array length

Julius Pfrommer 9 jaren geleden
bovenliggende
commit
80eb5fb0e5
3 gewijzigde bestanden met toevoegingen van 2 en 11 verwijderingen
  1. 2 3
      include/ua_types.h
  2. 0 5
      src/ua_types.c
  3. 0 3
      src/ua_types_encoding_binary.c

+ 2 - 3
include/ua_types.h

@@ -39,11 +39,11 @@ extern "C" {
  * ``T``.
  *
  * ``void T_init(T *ptr)``
- *   Initialize the data type. This is synonymous with zeroing out the memory, i.e. *memset(dataptr, 0, sizeof(T))*.
+ *   Initialize the data type. This is synonymous with zeroing out the memory, i.e. ``memset(dataptr, 0, sizeof(T))``.
  * ``T* T_new()``
  *   Allocate and return the memory for the data type. The memory is already initialized.
  * ``UA_StatusCode T_copy(const T *src, T *dst)``
- *   Copy the content of the data type. Returns *UA_STATUSCODE_GOOD* if it succeeded.
+ *   Copy the content of the data type. Returns ``UA_STATUSCODE_GOOD`` or ``UA_STATUSCODE_BADOUTOFMEMORY``.
  * ``void T_deleteMembers(T *ptr)``
  *   Delete the dynamically allocated content of the data type, but not the data type itself.
  * ``void T_delete(T *ptr)``
@@ -162,7 +162,6 @@ typedef uint32_t UA_StatusCode;
  * has length 0 and the data pointer is NULL. An array of length 0 also has
  * length 0 but points to a sentinel memory address. */
 #define UA_EMPTY_ARRAY_SENTINEL ((void*)0x01)
-#define MAX_ARRAY_SIZE 104857600 // arrays must be smaller than 100MB
 
 /** Forward Declaration of UA_DataType. See Section `Generic Type Handling`_
     for details. */

+ 0 - 5
src/ua_types.c

@@ -801,8 +801,6 @@ void UA_delete(void *p, const UA_DataType *type) {
 /******************/
 
 void * UA_Array_new(size_t size, const UA_DataType *type) {
-    if(size > MAX_ARRAY_SIZE || type->memSize * size > MAX_ARRAY_SIZE)
-        return NULL;
     if(size == 0)
         return UA_EMPTY_ARRAY_SENTINEL;
     return UA_calloc(size, type->memSize);
@@ -818,9 +816,6 @@ UA_Array_copy(const void *src, size_t src_size, void **dst, const UA_DataType *t
         return UA_STATUSCODE_GOOD;
     }
 
-    if(src_size > MAX_ARRAY_SIZE || type->memSize * src_size > MAX_ARRAY_SIZE)
-        return UA_STATUSCODE_BADOUTOFMEMORY;
-
     /* calloc, so we don't have to check retval in every iteration of copying */
     *dst = UA_calloc(src_size, type->memSize);
     if(!*dst)

+ 0 - 3
src/ua_types_encoding_binary.c

@@ -335,9 +335,6 @@ Array_decodeBinary(bufpos pos, bufend end, UA_Int32 signed_length, void *UA_REST
     }
     size_t length = (size_t)signed_length;
         
-    if(contenttype->memSize * length > MAX_ARRAY_SIZE)
-        return UA_STATUSCODE_BADOUTOFMEMORY;
-
     /* filter out arrays that can obviously not be parsed, because the message
        is too small */
     if(*pos + ((contenttype->memSize * length) / 32) > end)