From a7cb697abb4ba2b3301246592b7210bf6c485ddc Mon Sep 17 00:00:00 2001 From: Damien Zammit Date: Sat, 25 Jul 2015 03:29:32 +1000 Subject: Fixed start offset byte-length Signed-off-by: Damien Zammit --- ptfformat.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ptfformat.cc b/ptfformat.cc index 4ecd44c..04d6348 100644 --- a/ptfformat.cc +++ b/ptfformat.cc @@ -351,10 +351,20 @@ PTFFormat::parse(void) { //offset offset = 0; - offset |= (uint32_t)(ptfunxored[j]); - offset |= (uint32_t)(ptfunxored[j+1] << 8); - offset |= (uint32_t)(ptfunxored[j+2] << 16); - offset |= (uint32_t)(ptfunxored[j+3] << 24); + startbytes = (ptfunxored[k+3] & 0xf0) >> 4; + + switch (startbytes) { + case 4: + offset |= (uint32_t)(ptfunxored[j+3] << 24); + case 3: + offset |= (uint32_t)(ptfunxored[j+2] << 16); + case 2: + offset |= (uint32_t)(ptfunxored[j+1] << 8); + case 1: + offset |= (uint32_t)(ptfunxored[j]); + default: + break; + } of->posabsolute = (uint32_t)offset; of++; } -- cgit v1.2.3