All find*() and patch*() routines now return the buffer offset as an `int'.

committer: mfx <mfx> 976592518 +0000
This commit is contained in:
Markus F.X.J. Oberhumer
2000-12-12 03:41:58 +00:00
parent 1efd7f5cfa
commit b2e0f807f2
12 changed files with 153 additions and 112 deletions
+9 -6
View File
@@ -101,9 +101,10 @@ void PackHeader::putPackHeader(upx_bytep buf, unsigned len)
#if defined(UNUPX)
throwBadLoader();
#else
upx_bytep l = find_le32(buf,len,magic);
if (l == 0)
int offset = find_le32(buf,len,magic);
if (offset < 0)
throwBadLoader();
upx_bytep l = buf + offset;
l[4] = (unsigned char) version;
l[5] = (unsigned char) format;
@@ -163,14 +164,16 @@ void PackHeader::putPackHeader(upx_bytep buf, unsigned len)
bool PackHeader::fillPackHeader(upx_bytep buf, unsigned len)
{
upx_bytep l = find_le32(buf,len,magic);
if (l == 0)
int offset = find_le32(buf,len,magic);
if (offset < 0)
return false;
buf_offset = l - buf;
const int hlen = len - buf_offset;
const int hlen = len - offset;
if (hlen < 8)
return false;
upx_bytep l = buf + offset;
buf_offset = offset;
version = l[4];
format = l[5];
method = l[6];