aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sisfilerecord.cpp
diff options
context:
space:
mode:
authorDaniel Brahneborg <basic@chello.se>2002-03-28 09:47:25 +0000
committerDaniel Brahneborg <basic@chello.se>2002-03-28 09:47:25 +0000
commit81e05de4391c11fad7faf9bc164f92e128a49d25 (patch)
treed69f635c5986154f4e629a8f16de42676ccbbf11 /lib/sisfilerecord.cpp
parent1d9b2e0e156f9a58bd642b9f9e8b2a08e768f5ed (diff)
downloadplptools-81e05de4391c11fad7faf9bc164f92e128a49d25.tar.gz
plptools-81e05de4391c11fad7faf9bc164f92e128a49d25.tar.bz2
plptools-81e05de4391c11fad7faf9bc164f92e128a49d25.zip
Some buffer overrun checks.
Removed the --force flag.
Diffstat (limited to 'lib/sisfilerecord.cpp')
-rw-r--r--lib/sisfilerecord.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/lib/sisfilerecord.cpp b/lib/sisfilerecord.cpp
index 95e75ed..a483b80 100644
--- a/lib/sisfilerecord.cpp
+++ b/lib/sisfilerecord.cpp
@@ -32,7 +32,9 @@ SISFileRecord::fillFrom(uint8_t* buf, int* base, off_t len, SISFile* sisFile)
if (*base + 28 + 4 * 2 > len)
return SIS_TRUNCATED;
+ SisRC rc = SIS_OK;
m_buf = buf;
+ m_len = len;
uint8_t* p = buf + *base;
int size = 0;
m_flags = read32(p);
@@ -89,16 +91,16 @@ SISFileRecord::fillFrom(uint8_t* buf, int* base, off_t len, SISFile* sisFile)
for (int i = 0; i < n; ++i)
{
m_fileLengths[i] = read32(p + size);
- if (m_fileLengths[i] > len)
- return SIS_TRUNCATED;
+// if (m_fileLengths[i] > len)
+// rc = SIS_TRUNCATEDDATA;
size += 4;
}
for (int i = 0; i < n; ++i)
{
m_filePtrs[i] = read32(p + size);
int fileLen = m_fileLengths[i];
- if (m_filePtrs[i] + fileLen > len)
- return SIS_TRUNCATED;
+// if (m_filePtrs[i] + fileLen > len)
+// rc = SIS_TRUNCATEDDATA;
size += 4;
if (logLevel >= 2)
printf(_("File %d (for %s) is %d bytes long (at %d)\n"),
@@ -122,7 +124,17 @@ SISFileRecord::fillFrom(uint8_t* buf, int* base, off_t len, SISFile* sisFile)
printf(_("Unknown file flags %d\n"), m_flags);
}
*base += size;
- return SIS_OK;
+ return rc;
+}
+
+uint8_t*
+SISFileRecord::getFilePtr(int fileNo)
+{
+ if (fileNo < 0)
+ return 0;
+ if (m_filePtrs[fileNo] >= m_len)
+ return 0;
+ return &m_buf[m_filePtrs[fileNo]];
}
void