From 935ba6f596226205e57946e900244e3a530e9202 Mon Sep 17 00:00:00 2001
From: Gabor Szalai <gabor.szalai@ericsson.com>
Date: Thu, 15 Jul 2021 17:47:34 +0200
Subject: [PATCH] RAW decoder overindex fix (issue #558)

Prevent the overindexing during the decoding of the last fields

Signed-off-by: Gabor Szalai <gabor.szalai@ericsson.com>
---
 core/Encdec.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/core/Encdec.cc b/core/Encdec.cc
index cfa24d7f7..b6583b1e0 100644
--- a/core/Encdec.cc
+++ b/core/Encdec.cc
@@ -1411,6 +1411,7 @@ unsigned char TTCN_Buffer::get_byte_align(size_t len,
                                           size_t idx)
 {
   if(idx>(bit_pos+len)/8) return '\0';
+  if((buf_pos+idx) >= buf_len) return '\0';
   const unsigned char *data_ptr = buf_ptr != NULL ? buf_ptr->data_ptr : NULL;
   if(idx==0){ // first byte
     if(fieldorder==req_align){
-- 
GitLab