diff --git a/programs/cmp_tool.c b/programs/cmp_tool.c
index 20e2fb90bb8b218e345c860b82f95512b47205ca..31184bab007bb6399910850442f2fcb9f09355b0 100644
--- a/programs/cmp_tool.c
+++ b/programs/cmp_tool.c
@@ -45,6 +45,7 @@
 
 #define DEFAULT_MODEL_ID 53264  /* random default id */
 
+
 /**
  * @brief checks if an optional argument is present
  *
@@ -429,6 +430,11 @@ int CMP_MAIN(int argc, char **argv)
 			input_size = (uint32_t)size;
 		}
 
+		if (input_size > CMP_ENTITY_MAX_ORIGINAL_SIZE) {
+			fprintf(stderr, "%s: Error input data size is to large; maximum original data size: %lu\n", PROGRAM_NAME, CMP_ENTITY_MAX_ORIGINAL_SIZE);
+			goto fail;
+		}
+
 		rcfg.input_buf = malloc(input_size);
 		if (!rcfg.input_buf) {
 			fprintf(stderr, "%s: Error allocating memory for input data buffer.\n", PROGRAM_NAME);
@@ -853,6 +859,10 @@ static int compression_for_rdcu(struct rdcu_cfg *rcfg)
 
 	printf("Compress data ... ");
 	out_buf_size = rcfg->buffer_length * sizeof(uint16_t);
+	if (out_buf_size > CMP_ENTITY_MAX_SIZE * BUFFER_LENGTH_DEF_FAKTOR) {
+		fprintf(stderr, "%s: Error buffer_length parameter to large.\n", PROGRAM_NAME);
+		goto error_cleanup;
+	}
 	cmp_entity = calloc(1, out_buf_size + sizeof(struct cmp_entity));
 	if (cmp_entity == NULL) {
 		fprintf(stderr, "%s: Error allocating memory for output buffer.\n", PROGRAM_NAME);