From f1f20db42313032578ba256903d0004dd126a60a Mon Sep 17 00:00:00 2001 From: Daniel Brahneborg Date: Sun, 14 Apr 2002 12:03:02 +0000 Subject: More correct residual sis file truncation --- lib/siscomponentrecord.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'lib/siscomponentrecord.cpp') diff --git a/lib/siscomponentrecord.cpp b/lib/siscomponentrecord.cpp index 3507bce..ac5ba6d 100644 --- a/lib/siscomponentrecord.cpp +++ b/lib/siscomponentrecord.cpp @@ -35,12 +35,15 @@ SISComponentNameRecord::~SISComponentNameRecord() } SisRC -SISComponentNameRecord::fillFrom(uint8_t* buf, int base, off_t len, +SISComponentNameRecord::fillFrom(uint8_t* buf, int* basePos, off_t len, SISFile* sisFile) { int n = sisFile->m_header.m_nlangs; - if (base + 8 + n * 4 * 2 > len) + int base = *basePos; + int entrySize = 8 + n * 4 * 2; + if (base + entrySize > len) return SIS_TRUNCATED; + *basePos += entrySize; uint8_t* p = buf + base; int size = 0; @@ -90,6 +93,19 @@ SISComponentNameRecord::fillFrom(uint8_t* buf, int base, off_t len, return SIS_OK; } +uint32_t +SISComponentNameRecord::getLastEnd() +{ + uint32_t last = 0; + for (int i = 0; i < m_nameCount; ++i) + { + uint32_t pos = m_namePtrs[i] + m_nameLengths[i]; + if (last < pos) + last = pos; + } + return last; +} + uint8_t* SISComponentNameRecord::getName(int no) { -- cgit v1.2.3