Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e3d43df5f | ||
|
|
c1d6b29d94 | ||
|
|
8fc7253bba | ||
|
|
ac2bde2550 |
@@ -1,6 +1,11 @@
|
||||
RABCDAsm Changelog
|
||||
==================
|
||||
|
||||
RABCDAsm v1.13 (2012.09.29)
|
||||
---------------------------
|
||||
|
||||
* Fixed handling of truncated SWF tags
|
||||
|
||||
RABCDAsm v1.12 (2012.09.08)
|
||||
---------------------------
|
||||
|
||||
|
||||
+2
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010, 2011 Vladimir Panteleev <vladimir@thecybershadow.net>
|
||||
* Copyright 2010, 2011, 2012 Vladimir Panteleev <vladimir@thecybershadow.net>
|
||||
* This file is part of RABCDAsm.
|
||||
*
|
||||
* RABCDAsm is free software: you can redistribute it and/or modify
|
||||
@@ -41,6 +41,7 @@ void main(string[] args)
|
||||
while (*p++) {} // skip name
|
||||
tag.data = tag.data[0..p-tag.data.ptr] ~ abc;
|
||||
}
|
||||
tag.length = cast(uint)tag.data.length;
|
||||
write(args[1], swf.write());
|
||||
return;
|
||||
}
|
||||
|
||||
+1
-1
@@ -668,7 +668,7 @@ private final class ABCtoAS
|
||||
postConvertMultiname(multiname, multinames[i]);
|
||||
|
||||
methods.length = methodAdded.length = abc.methods.length;
|
||||
foreach (i, ref method; abc.methods)
|
||||
foreach (uint i, ref method; abc.methods)
|
||||
methods[i] = convertMethod(method, i);
|
||||
|
||||
metadata.length = abc.metadata.length;
|
||||
|
||||
+8
-8
@@ -67,7 +67,7 @@ final class Assembler
|
||||
return File(name, data, data.ptr, data.ptr + data.length, arguments, basePath);
|
||||
}
|
||||
|
||||
Position position()
|
||||
@property Position position()
|
||||
{
|
||||
Position p;
|
||||
p.filename = filename;
|
||||
@@ -75,7 +75,7 @@ final class Assembler
|
||||
return p;
|
||||
}
|
||||
|
||||
string positionStr()
|
||||
@property string positionStr()
|
||||
{
|
||||
auto lines = splitLines(buf);
|
||||
foreach (i, line; lines)
|
||||
@@ -104,7 +104,7 @@ final class Assembler
|
||||
foreach (ref c; buf)
|
||||
if (c == '\\')
|
||||
c = '/';
|
||||
return buildPath(getBasePath, buf);
|
||||
return buildPath(getBasePath(), buf);
|
||||
}
|
||||
|
||||
void skipWhitespace()
|
||||
@@ -573,7 +573,7 @@ final class Assembler
|
||||
if (pindex)
|
||||
n.id = *pindex;
|
||||
else
|
||||
n.id = namespaceLabels[name] = namespaceLabels.length+1;
|
||||
n.id = namespaceLabels[name] = cast(uint)namespaceLabels.length+1;
|
||||
}
|
||||
expectChar(')');
|
||||
return n;
|
||||
@@ -1100,13 +1100,13 @@ final class Assembler
|
||||
|
||||
foreach (ref f; jumpFixups)
|
||||
{
|
||||
scope(failure) setFile(f.where.load);
|
||||
scope(failure) setFile(f.where.load());
|
||||
instructions[f.ii].arguments[f.ai].jumpTarget = parseLabel(f.name, labels);
|
||||
}
|
||||
|
||||
foreach (ref f; switchFixups)
|
||||
{
|
||||
scope(failure) setFile(f.where.load);
|
||||
scope(failure) setFile(f.where.load());
|
||||
instructions[f.ii].arguments[f.ai].switchTargets[f.si] = parseLabel(f.name, labels);
|
||||
}
|
||||
|
||||
@@ -1211,7 +1211,7 @@ final class Assembler
|
||||
auto cp = f.name in classesByID;
|
||||
if (cp is null)
|
||||
{
|
||||
setFile(f.where.load);
|
||||
setFile(f.where.load());
|
||||
throw new Exception("Unknown class refid: " ~ f.name);
|
||||
}
|
||||
*f.ptr = *cp;
|
||||
@@ -1225,7 +1225,7 @@ final class Assembler
|
||||
auto mp = f.name in methodsByID;
|
||||
if (mp is null)
|
||||
{
|
||||
setFile(f.where.load);
|
||||
setFile(f.where.load());
|
||||
throw new Exception("Unknown method refid: " ~ f.name);
|
||||
}
|
||||
*f.ptr = *mp;
|
||||
|
||||
+8
-4
@@ -389,11 +389,15 @@ final class RefBuilder : ASTraitsVisitor
|
||||
if (nsSimilar(ns1, ns2))
|
||||
{
|
||||
assert(name1 != name2); // handled by similar() check
|
||||
assert(!truncate); // handled above
|
||||
if (name2.length)
|
||||
return [c1, ContextItem(name2)];
|
||||
static if (truncate)
|
||||
assert(false); // handled above
|
||||
else
|
||||
return [c1];
|
||||
{
|
||||
if (name2.length)
|
||||
return [c1, ContextItem(name2)];
|
||||
else
|
||||
return [c1];
|
||||
}
|
||||
}
|
||||
|
||||
if (ns1.name.length > ns2.name.length && truncate)
|
||||
|
||||
@@ -40,9 +40,9 @@ static assert(LZMAHeader.sizeof == 13);
|
||||
|
||||
ubyte[] lzmaDecompress(LZMAHeader header, in ubyte[] compressedData)
|
||||
{
|
||||
enforce(header.decompressedSize > 0, "Decompression with unknown size is unsupported");
|
||||
enforce(header.decompressedSize > 0, "Decompression with unknown size is unsupported");
|
||||
|
||||
lzma_stream strm;
|
||||
lzma_stream strm;
|
||||
lzmaEnforce(lzma_alone_decoder(&strm, ulong.max), "lzma_alone_decoder");
|
||||
scope(exit) lzma_end(&strm);
|
||||
|
||||
@@ -54,7 +54,7 @@ ubyte[] lzmaDecompress(LZMAHeader header, in ubyte[] compressedData)
|
||||
{
|
||||
strm.next_in = chunk.ptr;
|
||||
strm.avail_in = chunk.length;
|
||||
lzmaEnforce(lzma_code(&strm, lzma_action.LZMA_RUN), "lzma_code");
|
||||
lzmaEnforce!true(lzma_code(&strm, lzma_action.LZMA_RUN), "lzma_code (LZMA_RUN)");
|
||||
enforce(strm.avail_in == 0, "Not all data was read");
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ ubyte[] lzmaDecompress(LZMAHeader header, in ubyte[] compressedData)
|
||||
decompress(cast(ubyte[])(&header)[0..1]);
|
||||
decompress(compressedData);
|
||||
|
||||
lzmaEnforce(lzma_code(&strm, lzma_action.LZMA_FINISH), "lzma_code");
|
||||
lzmaEnforce!true(lzma_code(&strm, lzma_action.LZMA_FINISH), "lzma_code (LZMA_FINISH)");
|
||||
|
||||
enforce(strm.avail_out == 0, "Decompressed size mismatch");
|
||||
|
||||
@@ -71,30 +71,31 @@ ubyte[] lzmaDecompress(LZMAHeader header, in ubyte[] compressedData)
|
||||
|
||||
ubyte[] lzmaCompress(in ubyte[] decompressedData, LZMAHeader* header)
|
||||
{
|
||||
lzma_options_lzma opts;
|
||||
enforce(lzma_lzma_preset(&opts, 9 | LZMA_PRESET_EXTREME) == false, "lzma_lzma_preset error");
|
||||
lzma_options_lzma opts;
|
||||
enforce(lzma_lzma_preset(&opts, 9 | LZMA_PRESET_EXTREME) == false, "lzma_lzma_preset error");
|
||||
|
||||
lzma_stream strm;
|
||||
lzma_stream strm;
|
||||
lzmaEnforce(lzma_alone_encoder(&strm, &opts), "lzma_alone_encoder");
|
||||
scope(exit) lzma_end(&strm);
|
||||
|
||||
auto outBuf = new ubyte[decompressedData.length];
|
||||
auto outBuf = new ubyte[decompressedData.length + 1024];
|
||||
strm.next_out = outBuf.ptr;
|
||||
strm.avail_out = outBuf.length;
|
||||
strm.next_in = decompressedData.ptr;
|
||||
strm.avail_in = decompressedData.length;
|
||||
lzmaEnforce(lzma_code(&strm, lzma_action.LZMA_RUN), "lzma_code");
|
||||
lzmaEnforce(lzma_code(&strm, lzma_action.LZMA_RUN), "lzma_code (LZMA_RUN)");
|
||||
scope(failure) { import std.stdio; writeln("avail_in=", strm.avail_in); }
|
||||
enforce(strm.avail_in == 0, "Not all data was read");
|
||||
enforce(strm.avail_out != 0, "Ran out of compression space");
|
||||
|
||||
lzmaEnforce(lzma_code(&strm, lzma_action.LZMA_FINISH), "lzma_code");
|
||||
lzmaEnforce!true(lzma_code(&strm, lzma_action.LZMA_FINISH), "lzma_code (LZMA_FINISH)");
|
||||
|
||||
*header = *cast(LZMAHeader*)outBuf.ptr;
|
||||
return outBuf[LZMAHeader.sizeof..to!size_t(strm.total_out)];
|
||||
}
|
||||
|
||||
private void lzmaEnforce(lzma_ret v, string f)
|
||||
private void lzmaEnforce(bool STREAM_END_OK=false)(lzma_ret v, string f)
|
||||
{
|
||||
if (v != lzma_ret.LZMA_OK && v != lzma_ret.LZMA_STREAM_END)
|
||||
throw new Exception(text(f, " error: ", v));
|
||||
if (v != lzma_ret.LZMA_OK && (!STREAM_END_OK || v != lzma_ret.LZMA_STREAM_END))
|
||||
throw new Exception(text(f, " error: ", v));
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010, 2011 Vladimir Panteleev <vladimir@thecybershadow.net>
|
||||
* Copyright 2010, 2011, 2012 Vladimir Panteleev <vladimir@thecybershadow.net>
|
||||
* This file is part of RABCDAsm.
|
||||
*
|
||||
* RABCDAsm is free software: you can redistribute it and/or modify
|
||||
@@ -33,6 +33,7 @@ void main(string[] args)
|
||||
{
|
||||
auto bin = cast(ubyte[])read(args[3]);
|
||||
tag.data = tag.data[0..6] ~ bin;
|
||||
tag.length = cast(uint)tag.data.length;
|
||||
write(args[1], swf.write());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ final class SWFFile
|
||||
{
|
||||
ushort type;
|
||||
ubyte[] data;
|
||||
uint length; // may be >data.length if file is truncated
|
||||
bool forceLongLength;
|
||||
}
|
||||
|
||||
@@ -129,10 +130,12 @@ private final class SWFReader
|
||||
pos += raw.length;
|
||||
}
|
||||
|
||||
/// May read less than len on EOF
|
||||
void[] readRaw(size_t len)
|
||||
{
|
||||
auto data = buf[pos..pos+len];
|
||||
pos += len;
|
||||
auto end = pos+len;
|
||||
auto data = buf[pos..end<$?end:$];
|
||||
pos = end;
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -174,6 +177,7 @@ private final class SWFReader
|
||||
if (length < 0x3F)
|
||||
t.forceLongLength = true;
|
||||
}
|
||||
t.length = length;
|
||||
t.data = cast(ubyte[])readRaw(length);
|
||||
return t;
|
||||
}
|
||||
@@ -263,16 +267,16 @@ private final class SWFWriter
|
||||
foreach (ref tag; swf.tags)
|
||||
{
|
||||
ushort u = cast(ushort)(tag.type << 6);
|
||||
if (tag.data.length < 0x3F && !tag.forceLongLength)
|
||||
if (tag.length < 0x3F && !tag.forceLongLength)
|
||||
{
|
||||
u |= tag.data.length;
|
||||
u |= tag.length;
|
||||
buf ~= toArray(u);
|
||||
}
|
||||
else
|
||||
{
|
||||
u |= 0x3F;
|
||||
buf ~= toArray(u);
|
||||
uint l = to!uint(tag.data.length);
|
||||
uint l = to!uint(tag.length);
|
||||
buf ~= toArray(l);
|
||||
}
|
||||
buf ~= tag.data;
|
||||
|
||||
Reference in New Issue
Block a user