You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(12) |
Sep
(20) |
Oct
(3) |
Nov
(17) |
Dec
(22) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(37) |
Feb
(12) |
Mar
(7) |
Apr
(27) |
May
(10) |
Jun
(2) |
Jul
(2) |
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
(2) |
Sep
(7) |
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
(12) |
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(1) |
Oct
|
Nov
(2) |
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <mat...@us...> - 2012-03-23 22:01:44
|
Revision: 173
http://bugreport.svn.sourceforge.net/bugreport/?rev=173&view=rev
Author: matt_hargett
Date: 2012-03-23 22:01:33 +0000 (Fri, 23 Mar 2012)
Log Message:
-----------
Code cleanup with latest ReSharper 7.x and VS2012 build.
Modified Paths:
--------------
AbstractBufferTest.cs
AnalysisEngine.csproj
BitMath.cs
DebuggerView.cs
InvalidOpcodeException.cs
MainTest.cs
Options.cs
RegisterCollection.cs
TextUI.csproj
X86Emulator.cs
X86EmulatorTest.cs
X86Opcode.cs
X86OpcodeTest.cs
Modified: AbstractBufferTest.cs
===================================================================
--- AbstractBufferTest.cs 2009-11-15 01:00:00 UTC (rev 172)
+++ AbstractBufferTest.cs 2012-03-23 22:01:33 UTC (rev 173)
@@ -207,7 +207,7 @@
}
[Test]
- [ExpectedException(typeof(ArgumentException))]
+ [ExpectedException(typeof(ArgumentNullException))]
public void PointerUnknownOperation()
{
new AbstractBuffer(new AbstractValue[] {}).DoOperation(OperatorEffect.Unknown, null);
Modified: AnalysisEngine.csproj
===================================================================
--- AnalysisEngine.csproj 2009-11-15 01:00:00 UTC (rev 172)
+++ AnalysisEngine.csproj 2012-03-23 22:01:33 UTC (rev 173)
@@ -59,15 +59,20 @@
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
- <CodeAnalysisRuleSet>Migrated rules for AnalysisEngine.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSet>BasicDesignGuidelineRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules />
<Optimize>true</Optimize>
+ <PlatformTarget>x64</PlatformTarget>
+ <ErrorReport>send</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<CodeAnalysisRuleSet>Migrated rules for AnalysisEngine.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules />
<Optimize>true</Optimize>
</PropertyGroup>
+ <PropertyGroup>
+ <RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
+ </PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="nunit.framework">
@@ -89,16 +94,13 @@
<Compile Include="Analyzer.cs" />
<Compile Include="AnalyzerTest.cs" />
<Compile Include="BitMathTest.cs" />
- <Compile Include="Block.cs" />
<Compile Include="Contract.cs" />
<Compile Include="CoverageExcludeAttribute.cs" />
- <Compile Include="DifferenceEngineTest.cs" />
<Compile Include="DumpFileParserTest.cs" />
<Compile Include="ElfFileParser.cs" />
<Compile Include="ElfFileParserTest.cs" />
<Compile Include="GLibcStartMainContract.cs" />
<Compile Include="GLibcStartMainContractTest.cs" />
- <Compile Include="GlobalSuppressions.cs" />
<Compile Include="InvalidOpcodeException.cs" />
<Compile Include="MachineStateTest.cs" />
<Compile Include="MallocContract.cs" />
@@ -128,13 +130,6 @@
<Compile Include="X86Opcode.cs" />
</ItemGroup>
<ItemGroup>
- <None Include="Migrated rules for AnalysisEngine.ruleset" />
- <None Include="Properties\Settings.settings">
- <Generator>SettingsSingleFileGenerator</Generator>
- <LastGenOutput>Settings.Designer.cs</LastGenOutput>
- </None>
- </ItemGroup>
- <ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
@@ -151,4 +146,10 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
+ <ItemGroup>
+ <None Include="Properties\Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
+ </ItemGroup>
</Project>
\ No newline at end of file
Modified: BitMath.cs
===================================================================
--- BitMath.cs 2009-11-15 01:00:00 UTC (rev 172)
+++ BitMath.cs 2012-03-23 22:01:33 UTC (rev 173)
@@ -25,7 +25,7 @@
for (var i = 0; i < DWORD_SIZE; ++i)
{
- result |= (UInt32)data[i + index] << (8*i);
+ result |= (UInt32)data[i + index] << (8 * i);
}
return result;
Modified: DebuggerView.cs
===================================================================
--- DebuggerView.cs 2009-11-15 01:00:00 UTC (rev 172)
+++ DebuggerView.cs 2012-03-23 22:01:33 UTC (rev 173)
@@ -84,7 +84,7 @@
}
// magic numbers that happen to look good :)
- var numberOfTabs = 3 - (code.Length/3);
+ var numberOfTabs = 3 - (code.Length / 3);
for (var i = 0; i < numberOfTabs; i++)
{
Console.Write("\t");
Modified: InvalidOpcodeException.cs
===================================================================
--- InvalidOpcodeException.cs 2009-11-15 01:00:00 UTC (rev 172)
+++ InvalidOpcodeException.cs 2012-03-23 22:01:33 UTC (rev 173)
@@ -3,6 +3,7 @@
namespace bugreport
{
+ [Serializable]
public sealed class InvalidOpcodeException : Exception
{
public InvalidOpcodeException(params Byte[] code)
Modified: MainTest.cs
===================================================================
--- MainTest.cs 2009-11-15 01:00:00 UTC (rev 172)
+++ MainTest.cs 2012-03-23 22:01:33 UTC (rev 173)
@@ -51,13 +51,13 @@
var analysisProcess = new Process
{
StartInfo =
- {
- FileName = "bugreport.exe",
- Arguments = "\"" + fileName + "\"",
- RedirectStandardOutput = true,
- UseShellExecute = false,
- CreateNoWindow = false
- }
+ {
+ FileName = "bugreport.exe",
+ Arguments = "\"" + fileName + "\"",
+ RedirectStandardOutput = true,
+ UseShellExecute = false,
+ CreateNoWindow = false
+ }
};
return analysisProcess;
Modified: Options.cs
===================================================================
--- Options.cs 2009-11-15 01:00:00 UTC (rev 172)
+++ Options.cs 2012-03-23 22:01:33 UTC (rev 173)
@@ -42,21 +42,21 @@
private static String GetFunctionToAnalyzeFrom(String[] arguments)
{
- for (var i = 0; i < arguments.Length; i++)
+ foreach (var argument in arguments)
{
- if (!arguments[i].StartsWith("--function"))
+ if (!argument.StartsWith("--function"))
{
continue;
}
- var indexOfEquals = arguments[i].IndexOf('=');
+ var indexOfEquals = argument.IndexOf('=');
if (indexOfEquals == -1)
{
throw new ArgumentException("--function malformed, should be in the form of --function=name");
}
- return arguments[i].Substring(indexOfEquals + 1);
+ return argument.Substring(indexOfEquals + 1);
}
return "_start";
Modified: RegisterCollection.cs
===================================================================
--- RegisterCollection.cs 2009-11-15 01:00:00 UTC (rev 172)
+++ RegisterCollection.cs 2012-03-23 22:01:33 UTC (rev 173)
@@ -94,7 +94,7 @@
result.Append("\t");
}
- if ((i + 1)%4 == 0)
+ if ((i + 1) % 4 == 0)
{
result.Append(Environment.NewLine);
}
Modified: TextUI.csproj
===================================================================
--- TextUI.csproj 2009-11-15 01:00:00 UTC (rev 172)
+++ TextUI.csproj 2012-03-23 22:01:33 UTC (rev 173)
@@ -61,7 +61,7 @@
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
- <CodeAnalysisRuleSet>Migrated rules for AnalysisEngine.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSet>BasicCorrectnessRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules />
<Optimize>true</Optimize>
</PropertyGroup>
@@ -85,6 +85,7 @@
<Compile Include="DebuggerCommand.cs" />
<Compile Include="DebuggerView.cs" />
<Compile Include="DebuggerCommandTest.cs" />
+ <Compile Include="GlobalSuppressions.cs" />
<Compile Include="Main.cs" />
<Compile Include="MainTest.cs" />
<Compile Include="OpcodeFormatter.cs" />
@@ -97,10 +98,6 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
- <None Include="app.config" />
- <None Include="Migrated rules for TextUI.ruleset" />
- </ItemGroup>
- <ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
Modified: X86Emulator.cs
===================================================================
--- X86Emulator.cs 2009-11-15 01:00:00 UTC (rev 172)
+++ X86Emulator.cs 2012-03-23 22:01:33 UTC (rev 173)
@@ -194,7 +194,7 @@
var scaledRegisterValue = state.Registers[SIB.GetScaledRegister(code)].Value;
var scaler = SIB.GetScaler(code);
baseRegisterValue = state.Registers[SIB.GetBaseRegister(code)];
- index = (Int32)(scaledRegisterValue*scaler);
+ index = (Int32)(scaledRegisterValue * scaler);
}
else
{
Modified: X86EmulatorTest.cs
===================================================================
--- X86EmulatorTest.cs 2009-11-15 01:00:00 UTC (rev 172)
+++ X86EmulatorTest.cs 2012-03-23 22:01:33 UTC (rev 173)
@@ -597,6 +597,34 @@
}
[Test]
+ public void PushESIThenPopESI()
+ {
+ var pushCode = new Byte[] {0x56};
+ var popCode = new Byte[] {0x5e};
+
+ state.Registers[RegisterName.ESI] = one;
+ state = X86Emulator.Run(reportItems, state, pushCode);
+ Assert.AreEqual(0x1, state.InstructionPointer);
+ state.Registers[RegisterName.ESI] = null;
+ state = X86Emulator.Run(reportItems, state, popCode);
+ Assert.AreEqual(0x2, state.InstructionPointer);
+ Assert.AreEqual(one, state.Registers[RegisterName.ESI]);
+ }
+
+ [Test]
+ public void PushESPThenPopESP()
+ {
+ var pushCode = new Byte[] {0x54};
+ var popCode = new Byte[] {0x5c};
+ state = X86Emulator.Run(reportItems, state, pushCode);
+
+ Assert.AreEqual(0x1, state.InstructionPointer);
+ state = X86Emulator.Run(reportItems, state, popCode);
+ Assert.AreEqual(0x2, state.InstructionPointer);
+ Assert.AreEqual(state.Registers[RegisterName.ESP], state.Registers[RegisterName.ESP]);
+ }
+
+ [Test]
public void PushEbpThenPopEbp()
{
var pushCode = new Byte[] {0x55};
@@ -667,34 +695,6 @@
}
[Test]
- public void PushESIThenPopESI()
- {
- var pushCode = new Byte[] {0x56};
- var popCode = new Byte[] {0x5e};
-
- state.Registers[RegisterName.ESI] = one;
- state = X86Emulator.Run(reportItems, state, pushCode);
- Assert.AreEqual(0x1, state.InstructionPointer);
- state.Registers[RegisterName.ESI] = null;
- state = X86Emulator.Run(reportItems, state, popCode);
- Assert.AreEqual(0x2, state.InstructionPointer);
- Assert.AreEqual(one, state.Registers[RegisterName.ESI]);
- }
-
- [Test]
- public void PushESPThenPopESP()
- {
- var pushCode = new Byte[] {0x54};
- var popCode = new Byte[] {0x5c};
- state = X86Emulator.Run(reportItems, state, pushCode);
-
- Assert.AreEqual(0x1, state.InstructionPointer);
- state = X86Emulator.Run(reportItems, state, popCode);
- Assert.AreEqual(0x2, state.InstructionPointer);
- Assert.AreEqual(state.Registers[RegisterName.ESP], state.Registers[RegisterName.ESP]);
- }
-
- [Test]
public void PushIzThenPopEbp()
{
var pushCode = new Byte[] {0x68, 0x10, 0x84, 0x04, 0x08};
Modified: X86Opcode.cs
===================================================================
--- X86Opcode.cs 2009-11-15 01:00:00 UTC (rev 172)
+++ X86Opcode.cs 2012-03-23 22:01:33 UTC (rev 173)
@@ -9,7 +9,7 @@
namespace bugreport
{
/// <summary>
- /// Based on table at http://sandpile.org/ia32/opc_1.htm
+ /// Based on table at http://sandpile.org/ia32/opc_1.htm
/// </summary>
public sealed class X86Opcode : Opcode
{
@@ -164,7 +164,8 @@
default:
{
- throw new NotImplementedException("Don't know how to get the immediate for this opcode: " + code[0]);
+ throw new NotImplementedException("Don't know how to get the immediate for this opcode: " +
+ code[0]);
}
}
}
Modified: X86OpcodeTest.cs
===================================================================
--- X86OpcodeTest.cs 2009-11-15 01:00:00 UTC (rev 172)
+++ X86OpcodeTest.cs 2012-03-23 22:01:33 UTC (rev 173)
@@ -505,6 +505,27 @@
}
[Test]
+ [ExpectedException(typeof(InvalidOpcodeException))]
+ public void UnknownOpcode()
+ {
+ code = new Byte[] {0xf0, 0x00};
+ opcode.GetEncodingFor(code);
+ }
+
+ [Test]
+ public void XorEvGv()
+ {
+ // xor EBP,EBP
+ code = new Byte[] {0x31, 0xed};
+ Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
+ encoding = opcode.GetEncodingFor(code);
+ Assert.AreEqual(OpcodeEncoding.EvGv, encoding);
+ Assert.AreEqual(OperatorEffect.Xor, opcode.GetOperatorEffectFor(code));
+ Assert.AreEqual(RegisterName.EBP, opcode.GetDestinationRegisterFor(code));
+ Assert.AreEqual(RegisterName.EBP, opcode.GetSourceRegisterFor(code));
+ }
+
+ [Test]
public void rAxIv()
{
code = new Byte[] {0xb8, 0x00, 0x00, 0x00, 0x00};
@@ -537,26 +558,5 @@
var operatorEffect = opcode.GetOperatorEffectFor(code);
Assert.AreEqual(OperatorEffect.Assignment, operatorEffect);
}
-
- [Test]
- [ExpectedException(typeof(InvalidOpcodeException))]
- public void UnknownOpcode()
- {
- code = new Byte[] {0xf0, 0x00};
- opcode.GetEncodingFor(code);
- }
-
- [Test]
- public void XorEvGv()
- {
- // xor EBP,EBP
- code = new Byte[] {0x31, 0xed};
- Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
- encoding = opcode.GetEncodingFor(code);
- Assert.AreEqual(OpcodeEncoding.EvGv, encoding);
- Assert.AreEqual(OperatorEffect.Xor, opcode.GetOperatorEffectFor(code));
- Assert.AreEqual(RegisterName.EBP, opcode.GetDestinationRegisterFor(code));
- Assert.AreEqual(RegisterName.EBP, opcode.GetSourceRegisterFor(code));
- }
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mat...@us...> - 2009-11-15 01:00:44
|
Revision: 172
http://bugreport.svn.sourceforge.net/bugreport/?rev=172&view=rev
Author: matt_hargett
Date: 2009-11-15 01:00:00 +0000 (Sun, 15 Nov 2009)
Log Message:
-----------
oops. fixed a test failure, but assigning to a parameter is a bad practice; need to figure out how to fix it and keep the tests passing.
Modified Paths:
--------------
X86Emulator.cs
Modified: X86Emulator.cs
===================================================================
--- X86Emulator.cs 2009-11-15 00:53:42 UTC (rev 171)
+++ X86Emulator.cs 2009-11-15 01:00:00 UTC (rev 172)
@@ -295,21 +295,19 @@
private static MachineState emulateStackEffectFor(byte[] code, MachineState state)
{
- MachineState modifiedState;
-
switch (opcode.GetStackEffectFor(code))
{
case StackEffect.Pop:
{
var destinationRegister = opcode.GetDestinationRegisterFor(code);
state.Registers[destinationRegister] = state.Registers[RegisterName.ESP].PointsTo[0];
- modifiedState = state.DoOperation(RegisterName.ESP, OperatorEffect.Sub, new AbstractValue(1));
+ state = state.DoOperation(RegisterName.ESP, OperatorEffect.Sub, new AbstractValue(1));
break;
}
case StackEffect.Push:
{
- modifiedState = state.DoOperation(RegisterName.ESP, OperatorEffect.Add, new AbstractValue(1));
+ state = state.DoOperation(RegisterName.ESP, OperatorEffect.Add, new AbstractValue(1));
AbstractValue sourceValue;
if (opcode.HasSourceRegister(code))
@@ -342,7 +340,7 @@
}
}
- return modifiedState;
+ return state;
}
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mat...@us...> - 2009-11-15 00:54:31
|
Revision: 171
http://bugreport.svn.sourceforge.net/bugreport/?rev=171&view=rev
Author: matt_hargett
Date: 2009-11-15 00:53:42 +0000 (Sun, 15 Nov 2009)
Log Message:
-----------
convert to VS2010 project. clean up almost all inspections/warnings reported by ReSharper 5.0. clean up a number of FxCop and Gendarme warnings. Next up: convert the old-style NUnit asserts to the (not so) new assertion syntax, unless someone beats me to it.
Modified Paths:
--------------
AbstractBuffer.cs
AbstractBufferTest.cs
AbstractValue.cs
AbstractValueTest.cs
AnalysisEngine.csproj
Analyzer.cs
AnalyzerTest.cs
AssemblyInfo.cs
BitMath.cs
BitMathTest.cs
CoverageExcludeAttribute.cs
DebuggerView.cs
DumpFileParser.cs
DumpFileParserTest.cs
ElfFileParser.cs
ElfFileParserTest.cs
GLibcStartMainContractTest.cs
MachineState.cs
MachineStateTest.cs
ModRM.cs
ModRMTest.cs
OpcodeFormatter.cs
Options.cs
OptionsTest.cs
RegisterCollection.cs
RegisterCollectionTest.cs
ReportItem.cs
ReportItemTest.cs
SIB.cs
SIBTests.cs
TextUI.csproj
X86Emulator.cs
X86EmulatorTest.cs
X86Opcode.cs
X86OpcodeTest.cs
bugreport.sln
tests/medium/interfunction-taint-parameter.c
tests/medium/simple-branch-oob-via-stack-unknown.c
Modified: AbstractBuffer.cs
===================================================================
--- AbstractBuffer.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ AbstractBuffer.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -14,12 +14,22 @@
public AbstractBuffer(AbstractValue[] values)
{
+ if (null == values)
+ {
+ throw new ArgumentNullException("values");
+ }
+
storage = values;
Length = storage.Length;
}
public AbstractBuffer(AbstractBuffer other)
{
+ if (null == other)
+ {
+ throw new ArgumentNullException("other");
+ }
+
BaseIndex = other.BaseIndex;
Length = other.Length;
storage = new AbstractValue[other.storage.Length];
@@ -37,7 +47,7 @@
// We check this.storage.Length as well so that we aren't calling Extend() when we dont need to.
if (IsIndexPastBounds(index))
{
- Extend(BaseIndex + (UInt32) index);
+ Extend(BaseIndex + (UInt32)index);
return storage[BaseIndex + index];
}
@@ -46,6 +56,11 @@
set
{
+ if (value == null)
+ {
+ throw new ArgumentNullException("value");
+ }
+
if ((BaseIndex + index) >= Length)
{
value.IsOutOfBounds = true;
@@ -53,7 +68,7 @@
if (IsIndexPastBounds(index))
{
- Extend(BaseIndex + (UInt32) index);
+ Extend(BaseIndex + (UInt32)index);
storage[BaseIndex + index] = value;
}
else
@@ -65,6 +80,11 @@
public AbstractBuffer DoOperation(OperatorEffect operatorEffect, AbstractValue rhs)
{
+ if (null == rhs)
+ {
+ throw new ArgumentNullException("rhs");
+ }
+
var lhs = this;
// TODO: should have a guard for if rhs isn't a pointer
Modified: AbstractBufferTest.cs
===================================================================
--- AbstractBufferTest.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ AbstractBufferTest.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -27,7 +27,7 @@
}
[Test]
- [ExpectedException(typeof (ArgumentOutOfRangeException))]
+ [ExpectedException(typeof(ArgumentOutOfRangeException))]
public void InvalidPointerAnd()
{
var one = new AbstractValue(0x1);
@@ -112,7 +112,7 @@
{
var values = AbstractValue.GetNewBuffer(4);
var buffer = new AbstractBuffer(values);
- var assignedBuffer = buffer.DoOperation(OperatorEffect.Assignment, null);
+ var assignedBuffer = buffer.DoOperation(OperatorEffect.Assignment, AbstractValue.Zero);
Assert.AreNotSame(buffer, assignedBuffer);
}
@@ -200,14 +200,14 @@
}
[Test]
- [ExpectedException(typeof (ArgumentOutOfRangeException))]
+ [ExpectedException(typeof(ArgumentOutOfRangeException))]
public void PointerSubUnderflow()
{
new AbstractBuffer(new AbstractValue[] {}).DoOperation(OperatorEffect.Sub, new AbstractValue(1));
}
[Test]
- [ExpectedException(typeof (ArgumentException))]
+ [ExpectedException(typeof(ArgumentException))]
public void PointerUnknownOperation()
{
new AbstractBuffer(new AbstractValue[] {}).DoOperation(OperatorEffect.Unknown, null);
Modified: AbstractValue.cs
===================================================================
--- AbstractValue.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ AbstractValue.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -13,6 +13,7 @@
{
public const UInt32 MAX_BUFFER_SIZE = 25600000;
public const UInt32 UNKNOWN = 0xb4dc0d3d;
+ private static readonly AbstractValue zero = new AbstractValue(0);
private readonly AbstractBuffer pointsTo;
private readonly UInt32 storage;
private Boolean tainted;
@@ -95,6 +96,11 @@
get { return pointsTo != null; }
}
+ public static AbstractValue Zero
+ {
+ get { return zero; }
+ }
+
public static AbstractValue[] GetNewBuffer(UInt32 size)
{
if (size > MAX_BUFFER_SIZE)
Modified: AbstractValueTest.cs
===================================================================
--- AbstractValueTest.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ AbstractValueTest.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -40,7 +40,7 @@
}
[Test]
- [ExpectedException(typeof (InvalidOperationException))]
+ [ExpectedException(typeof(InvalidOperationException))]
public void AddTaintOnPointer()
{
buffer = new AbstractBuffer(AbstractValue.GetNewBuffer(1));
@@ -68,7 +68,7 @@
}
[Test]
- [ExpectedException(typeof (ArgumentException))]
+ [ExpectedException(typeof(ArgumentException))]
public void EmptyBuffer()
{
pointer = new AbstractValue(new AbstractBuffer(new AbstractValue[] {}));
@@ -89,6 +89,18 @@
}
[Test]
+ public void IsOutOfBoundsPropertySurviviesCopy()
+ {
+ var src = new AbstractValue(0x31337)
+ {
+ IsOutOfBounds = true
+ };
+ var dest = new AbstractValue(src);
+
+ Assert.IsTrue(dest.IsOutOfBounds);
+ }
+
+ [Test]
public void NoPointer()
{
var value = new AbstractValue(2).AddTaint();
@@ -108,10 +120,10 @@
}
[Test]
- [ExpectedException(typeof (ArgumentNullException))]
+ [ExpectedException(typeof(ArgumentNullException))]
public void NullCopyCtor()
{
- pointer = new AbstractValue((AbstractValue) null);
+ pointer = new AbstractValue((AbstractValue)null);
}
[Test]
@@ -167,19 +179,7 @@
}
[Test]
- public void IsOutOfBoundsPropertySurviviesCopy()
- {
- var src = new AbstractValue(0x31337)
- {
- IsOutOfBounds = true
- };
- var dest = new AbstractValue(src);
-
- Assert.IsTrue(dest.IsOutOfBounds);
- }
-
- [Test]
- [ExpectedException(typeof (ArgumentOutOfRangeException))]
+ [ExpectedException(typeof(ArgumentOutOfRangeException))]
public void RequestedBufferTooLarge()
{
AbstractValue.GetNewBuffer(AbstractValue.MAX_BUFFER_SIZE + 1);
@@ -194,7 +194,7 @@
}
[Test]
- [ExpectedException(typeof (ArgumentException))]
+ [ExpectedException(typeof(ArgumentException))]
public void ZeroSizeBuffer()
{
pointer = new AbstractValue(new AbstractValue[] {});
Modified: AnalysisEngine.csproj
===================================================================
--- AnalysisEngine.csproj 2009-09-11 22:28:12 UTC (rev 170)
+++ AnalysisEngine.csproj 2009-11-15 00:53:42 UTC (rev 171)
@@ -1,4 +1,5 @@
-<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<ProjectGuid>{8DC8856B-6FF9-4E39-BF0B-1C1B55115273}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -16,7 +17,24 @@
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
- <OldToolsVersion>2.0</OldToolsVersion>
+ <OldToolsVersion>3.5</OldToolsVersion>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <PublishUrl>publish\</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Disk</InstallFrom>
+ <UpdateEnabled>false</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <IsWebBootstrapper>false</IsWebBootstrapper>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
+ <TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
@@ -40,6 +58,16 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
+ <CodeAnalysisRuleSet>Migrated rules for AnalysisEngine.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules />
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
+ <CodeAnalysisRuleSet>Migrated rules for AnalysisEngine.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules />
+ <Optimize>true</Optimize>
+ </PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="nunit.framework">
@@ -61,13 +89,16 @@
<Compile Include="Analyzer.cs" />
<Compile Include="AnalyzerTest.cs" />
<Compile Include="BitMathTest.cs" />
+ <Compile Include="Block.cs" />
<Compile Include="Contract.cs" />
<Compile Include="CoverageExcludeAttribute.cs" />
+ <Compile Include="DifferenceEngineTest.cs" />
<Compile Include="DumpFileParserTest.cs" />
<Compile Include="ElfFileParser.cs" />
<Compile Include="ElfFileParserTest.cs" />
<Compile Include="GLibcStartMainContract.cs" />
<Compile Include="GLibcStartMainContractTest.cs" />
+ <Compile Include="GlobalSuppressions.cs" />
<Compile Include="InvalidOpcodeException.cs" />
<Compile Include="MachineStateTest.cs" />
<Compile Include="MallocContract.cs" />
@@ -80,6 +111,11 @@
<Compile Include="MachineState.cs" />
<Compile Include="ModRM.cs" />
<Compile Include="Opcode.cs" />
+ <Compile Include="Properties\Settings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ <DependentUpon>Settings.settings</DependentUpon>
+ </Compile>
<Compile Include="X86Emulator.cs" />
<Compile Include="X86EmulatorTest.cs" />
<Compile Include="X86OpcodeTest.cs" />
@@ -91,4 +127,28 @@
<Compile Include="SIBTests.cs" />
<Compile Include="X86Opcode.cs" />
</ItemGroup>
+ <ItemGroup>
+ <None Include="Migrated rules for AnalysisEngine.ruleset" />
+ <None Include="Properties\Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
+ </ItemGroup>
+ <ItemGroup>
+ <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
+ <Visible>False</Visible>
+ <ProductName>Windows Installer 3.1</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ </ItemGroup>
</Project>
\ No newline at end of file
Modified: Analyzer.cs
===================================================================
--- Analyzer.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ Analyzer.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -103,7 +103,7 @@
public void Run()
{
- var machineState = new MachineState(GetRegistersForLinuxStart())
+ var machineState = new MachineState(createRegistersForLinuxStart())
{
InstructionPointer = parser.EntryPointAddress
};
@@ -136,7 +136,7 @@
return X86Emulator.Run(reportItems, _machineState, code);
}
- private static RegisterCollection GetRegistersForLinuxStart()
+ private static RegisterCollection createRegistersForLinuxStart()
{
var linuxMainDefaultValues = new RegisterCollection();
Modified: AnalyzerTest.cs
===================================================================
--- AnalyzerTest.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ AnalyzerTest.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -29,7 +29,7 @@
private IParsable CreateMockParser(UInt32 expectedReportItemCount)
{
- var control = new DynamicMock(typeof (IParsable));
+ var control = new DynamicMock(typeof(IParsable));
control.ExpectAndReturn("GetBytes", code, null);
var reportItemList = new List<ReportItem>();
@@ -61,7 +61,7 @@
ReportItems.Add(new ReportItem(i, false));
}
- machineState.InstructionPointer += (UInt32) instructionBytes.Length;
+ machineState.InstructionPointer += (UInt32)instructionBytes.Length;
return machineState;
}
@@ -77,7 +77,7 @@
}
[Test]
- [ExpectedException(typeof (ArgumentNullException))]
+ [ExpectedException(typeof(ArgumentNullException))]
public void NullStream()
{
analyzer = new Analyzer(null);
Modified: AssemblyInfo.cs
===================================================================
--- AssemblyInfo.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ AssemblyInfo.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -17,4 +17,4 @@
// You can specify all values by your own or you can build default build and revision
[assembly: AssemblyVersion("0.1.*")]
-[assembly: CLSCompliant(true)]
\ No newline at end of file
+[assembly: CLSCompliant(false)]
\ No newline at end of file
Modified: BitMath.cs
===================================================================
--- BitMath.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ BitMath.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -25,7 +25,7 @@
for (var i = 0; i < DWORD_SIZE; ++i)
{
- result |= (UInt32) data[i + index] << (8 * i);
+ result |= (UInt32)data[i + index] << (8*i);
}
return result;
Modified: BitMathTest.cs
===================================================================
--- BitMathTest.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ BitMathTest.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -20,21 +20,21 @@
}
[Test]
- [ExpectedException(typeof (ArgumentException))]
+ [ExpectedException(typeof(ArgumentException))]
public void EmptyBytes()
{
BitMath.BytesToDword(new Byte[] {}, 0);
}
[Test]
- [ExpectedException(typeof (ArgumentException))]
+ [ExpectedException(typeof(ArgumentException))]
public void NotEnoughBytesToDwordAtNonZeroIndex()
{
BitMath.BytesToDword(new Byte[] {0, 1, 2, 3}, 1);
}
[Test]
- [ExpectedException(typeof (ArgumentException))]
+ [ExpectedException(typeof(ArgumentException))]
public void NotEnoughBytesToDwordAtZeroIndex()
{
BitMath.BytesToDword(new Byte[] {0}, 0);
Modified: CoverageExcludeAttribute.cs
===================================================================
--- CoverageExcludeAttribute.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ CoverageExcludeAttribute.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -1,15 +1,15 @@
-// This file is part of bugreport.
-// Copyright (c) 2006-2009 The bugreport Developers.
-// See AUTHORS.txt for details.
-// Licensed under the GNU General Public License, Version 3 (GPLv3).
-// See LICENSE.txt for details.
-
+// This file is part of bugreport.
+// Copyright (c) 2006-2009 The bugreport Developers.
+// See AUTHORS.txt for details.
+// Licensed under the GNU General Public License, Version 3 (GPLv3).
+// See LICENSE.txt for details.
+
using System;
-namespace bugreport
-{
- [AttributeUsage(AttributeTargets.Method)]
+namespace bugreport
+{
+ [AttributeUsage(AttributeTargets.Method)]
public sealed class CoverageExcludeAttribute : Attribute
{
- }
+ }
}
\ No newline at end of file
Modified: DebuggerView.cs
===================================================================
--- DebuggerView.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ DebuggerView.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -35,7 +35,10 @@
private void HandleInputIfNecessary()
{
- if (!interactive) return;
+ if (!interactive)
+ {
+ return;
+ }
// TODO: cover this with a system-level test
var enterPressed = false;
@@ -81,7 +84,7 @@
}
// magic numbers that happen to look good :)
- var numberOfTabs = 3 - (code.Length / 3);
+ var numberOfTabs = 3 - (code.Length/3);
for (var i = 0; i < numberOfTabs; i++)
{
Console.Write("\t");
Modified: DumpFileParser.cs
===================================================================
--- DumpFileParser.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ DumpFileParser.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -181,9 +181,9 @@
private static ReportItem GetAnnotationFrom(String line)
{
- var locationIndex = line.IndexOf("=", StringComparison.Ordinal) + 1;
+ var locationIndex = line.IndexOf('=') + 1;
var location = UInt32.Parse(line.Substring(locationIndex + "/>".Length, 8), NumberStyles.HexNumber);
- var exploitableIndex = line.IndexOf("=", locationIndex + 1, StringComparison.Ordinal) + 1;
+ var exploitableIndex = line.IndexOf('=', locationIndex + 1) + 1;
var exploitable =
Boolean.Parse(line.Substring(exploitableIndex, (line.Length - exploitableIndex) - "/>".Length));
return new ReportItem(location, exploitable);
Modified: DumpFileParserTest.cs
===================================================================
--- DumpFileParserTest.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ DumpFileParserTest.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -40,12 +40,16 @@
[TestFixture]
public class WithNothingElseTest : DumpFileParserFixture
{
+ #region Setup/Teardown
+
[SetUp]
public override void SetUp()
{
base.SetUp();
}
+ #endregion
+
[Test]
public void EmptyLine()
{
@@ -112,7 +116,7 @@
}
[Test]
- [ExpectedException(typeof (FormatException))]
+ [ExpectedException(typeof(FormatException))]
public void LineWithBadHex()
{
writer.WriteLine(" 8048385: 83 ej 10 sub esp,0x10");
Modified: ElfFileParser.cs
===================================================================
--- ElfFileParser.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ ElfFileParser.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -23,6 +23,8 @@
textData = new Byte[stream.Length];
}
+ #region IDisposable Members
+
public void Dispose()
{
if (null != stream)
@@ -31,6 +33,10 @@
}
}
+ #endregion
+
+ #region IParsable Members
+
public UInt32 BaseAddress
{
get { return 0x080482e0; }
@@ -49,8 +55,10 @@
public Byte[] GetBytes()
{
stream.Seek(0x2e0, SeekOrigin.Begin);
- stream.Read(textData, 0, (Int32) (stream.Length - stream.Position));
+ stream.Read(textData, 0, (Int32)(stream.Length - stream.Position));
return textData;
}
+
+ #endregion
}
}
\ No newline at end of file
Modified: ElfFileParserTest.cs
===================================================================
--- ElfFileParserTest.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ ElfFileParserTest.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -27,11 +27,13 @@
[TearDown]
public void TearDown()
{
- if (parser != null)
+ if (parser == null)
{
- parser.Dispose();
- parser = null;
+ return;
}
+
+ parser.Dispose();
+ parser = null;
}
}
Modified: GLibcStartMainContractTest.cs
===================================================================
--- GLibcStartMainContractTest.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ GLibcStartMainContractTest.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -41,8 +41,7 @@
public void IsSatisified()
{
var code = new Byte[] {0xe8, 0xb7, 0xff, 0xff, 0xff};
- state = new MachineState();
- state.InstructionPointer = 0x80482fc;
+ state = new MachineState {InstructionPointer = 0x80482fc};
Assert.IsTrue(contract.IsSatisfiedBy(state, code));
state.InstructionPointer = 0xdeadbeef;
Modified: MachineState.cs
===================================================================
--- MachineState.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ MachineState.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -33,7 +33,7 @@
public override Boolean Equals(object obj)
{
- var operationResult = (OperationResult) obj;
+ var operationResult = (OperationResult)obj;
return Value.Equals(operationResult.Value) && ZeroFlag == operationResult.ZeroFlag;
}
@@ -123,7 +123,7 @@
public override Boolean Equals(object obj)
{
- var other = (MachineState) obj;
+ var other = (MachineState)obj;
if (!(instructionPointer == other.instructionPointer &&
registers.Equals(other.registers) &&
@@ -344,12 +344,12 @@
case OperatorEffect.Shr:
{
- return lhs >> (Byte) rhs;
+ return lhs >> (Byte)rhs;
}
case OperatorEffect.Shl:
{
- return lhs << (Byte) rhs;
+ return lhs << (Byte)rhs;
}
default:
Modified: MachineStateTest.cs
===================================================================
--- MachineStateTest.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ MachineStateTest.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -12,12 +12,16 @@
[TestFixture]
public class MachineStateTest
{
+ #region Setup/Teardown
+
[SetUp]
public void SetUp()
{
state = new MachineState(new RegisterCollection());
}
+ #endregion
+
private readonly AbstractValue one = new AbstractValue(1);
private readonly AbstractValue two = new AbstractValue(2).AddTaint();
private MachineState state;
@@ -158,7 +162,7 @@
}
[Test]
- [ExpectedException(typeof (ArgumentException))]
+ [ExpectedException(typeof(ArgumentException))]
public void JnzPointerOffset()
{
var pointer = new AbstractValue(AbstractValue.GetNewBuffer(1));
@@ -166,7 +170,7 @@
}
[Test]
- [ExpectedException(typeof (ArgumentException))]
+ [ExpectedException(typeof(ArgumentException))]
public void NonAssignmentOfPointer()
{
eax = one;
@@ -263,7 +267,7 @@
[Test]
public void PushTwiceThenManuallyAdjustStackThenAssignToEbp()
{
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(0x20);
+ var buffer = AbstractValue.GetNewBuffer(0x20);
esp = new AbstractValue(buffer);
state = state.PushOntoStack(one);
state = state.PushOntoStack(two);
@@ -295,7 +299,7 @@
}
[Test]
- [ExpectedException(typeof (ArgumentException))]
+ [ExpectedException(typeof(ArgumentException))]
public void Unknown()
{
state.DoOperation(RegisterName.EAX, OperatorEffect.Unknown, RegisterName.EBX);
Modified: ModRM.cs
===================================================================
--- ModRM.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ ModRM.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -14,7 +14,7 @@
private static Byte GetRMFor(Byte modrm)
{
- return (Byte) (modrm & 7);
+ return (Byte)(modrm & 7);
}
public static RegisterName GetEvFor(Byte[] code)
@@ -25,19 +25,19 @@
}
var modRM = GetModRMFor(code);
- return (RegisterName) (modRM & 7);
+ return (RegisterName)(modRM & 7);
}
internal static RegisterName GetGvFor(Byte[] code)
{
var modRM = GetModRMFor(code);
- return (RegisterName) ((modRM >> 3) & 7);
+ return (RegisterName)((modRM >> 3) & 7);
}
internal static Byte GetOpcodeGroupIndexFor(Byte[] code)
{
var modRM = GetModRMFor(code);
- return (Byte) ((modRM >> 3) & 7);
+ return (Byte)((modRM >> 3) & 7);
}
public static Boolean HasIndex(Byte[] code)
@@ -79,7 +79,7 @@
{
var modRM = GetModRMFor(code);
- return !(GetModFor(modRM) == 3);
+ return GetModFor(modRM) != 3;
}
public static Boolean HasOffset(Byte[] code)
@@ -134,7 +134,7 @@
private static Byte GetModFor(Byte modrm)
{
- return (Byte) ((modrm >> 6) & 3);
+ return (Byte)((modrm >> 6) & 3);
}
}
}
\ No newline at end of file
Modified: ModRMTest.cs
===================================================================
--- ModRMTest.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ ModRMTest.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -26,7 +26,7 @@
}
[Test]
- [ExpectedException(typeof (NotImplementedException))]
+ [ExpectedException(typeof(NotImplementedException))]
public void EaxEbpPlusDword12()
{
const int INDEX = 0x0c;
@@ -99,7 +99,7 @@
}
[Test]
- [ExpectedException(typeof (InvalidOperationException))]
+ [ExpectedException(typeof(InvalidOperationException))]
public void GetEvWithSIB()
{
code = new Byte[] {0xc7, 0x04, 0x24, 0x10, 0x00, 0x00, 0x00};
@@ -108,7 +108,7 @@
}
[Test]
- [ExpectedException(typeof (InvalidOperationException))]
+ [ExpectedException(typeof(InvalidOperationException))]
public void GetIndexWithNoIndex()
{
code = new Byte[] {0x89, 0xe5};
Modified: OpcodeFormatter.cs
===================================================================
--- OpcodeFormatter.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ OpcodeFormatter.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -168,7 +168,7 @@
throw new ArgumentException(
"don't know how to format this code's source operand: " + GetBytesFor(code)
- );
+ );
}
private static string GetSourceRegisterFor(byte[] code)
Modified: Options.cs
===================================================================
--- Options.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ Options.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -49,7 +49,7 @@
continue;
}
- var indexOfEquals = arguments[i].IndexOf("=", StringComparison.Ordinal);
+ var indexOfEquals = arguments[i].IndexOf('=');
if (indexOfEquals == -1)
{
Modified: OptionsTest.cs
===================================================================
--- OptionsTest.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ OptionsTest.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -115,7 +115,7 @@
}
[Test]
- [ExpectedException(typeof (ArgumentException))]
+ [ExpectedException(typeof(ArgumentException))]
public void FunctionNameWithoutEquals()
{
commandLine = new[]
Modified: RegisterCollection.cs
===================================================================
--- RegisterCollection.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ RegisterCollection.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -46,8 +46,8 @@
public AbstractValue this[RegisterName index]
{
- get { return registers[(Int32) index]; }
- set { registers[(Int32) index] = value; }
+ get { return registers[(Int32)index]; }
+ set { registers[(Int32)index] = value; }
}
public override Boolean Equals(object obj)
@@ -88,13 +88,13 @@
for (UInt32 i = 0; i < registers.Length; ++i)
{
var value = registers[i];
- result.Append(Enum.GetName(typeof (RegisterName), i) + "=" + value + "\t");
+ result.Append(Enum.GetName(typeof(RegisterName), i) + "=" + value + "\t");
if (value.ToString().Length < 8)
{
result.Append("\t");
}
- if ((i + 1) % 4 == 0)
+ if ((i + 1)%4 == 0)
{
result.Append(Environment.NewLine);
}
Modified: RegisterCollectionTest.cs
===================================================================
--- RegisterCollectionTest.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ RegisterCollectionTest.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -12,7 +12,7 @@
[TestFixture]
public class RegisterCollectionTest
{
- private RegisterCollection registers;
+ #region Setup/Teardown
[SetUp]
public void SetUp()
@@ -20,6 +20,10 @@
registers = new RegisterCollection();
}
+ #endregion
+
+ private RegisterCollection registers;
+
[Test]
public void Copy()
{
@@ -27,7 +31,7 @@
var newRegisters = new RegisterCollection(registers);
for (UInt32 i = 0; i < 7; i++)
{
- var register = (RegisterName) i;
+ var register = (RegisterName)i;
Assert.AreNotSame(newRegisters[register], registers[register]);
}
@@ -39,7 +43,7 @@
{
for (UInt32 i = 0; i < 7; i++)
{
- var register = (RegisterName) i;
+ var register = (RegisterName)i;
Assert.IsFalse(registers[register].IsInitialized);
}
}
Modified: ReportItem.cs
===================================================================
--- ReportItem.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ ReportItem.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -31,7 +31,7 @@
public override Boolean Equals(object obj)
{
- var report = (ReportItem) obj;
+ var report = (ReportItem)obj;
return InstructionPointer == report.InstructionPointer &&
IsTainted == report.IsTainted;
}
Modified: ReportItemTest.cs
===================================================================
--- ReportItemTest.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ ReportItemTest.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -1,31 +1,31 @@
-// This file is part of bugreport.
-// Copyright (c) 2006-2009 The bugreport Developers.
-// See AUTHORS.txt for details.
-// Licensed under the GNU General Public License, Version 3 (GPLv3).
-// See LICENSE.txt for details.
-
+// This file is part of bugreport.
+// Copyright (c) 2006-2009 The bugreport Developers.
+// See AUTHORS.txt for details.
+// Licensed under the GNU General Public License, Version 3 (GPLv3).
+// See LICENSE.txt for details.
+
using NUnit.Framework;
-namespace bugreport
-{
- [TestFixture]
- public class ReportItemTest
- {
- [Test]
- public void Equality()
- {
- var same = new ReportItem(123, false);
- var same2 = new ReportItem(123, false);
- var different = new ReportItem(456, false);
-
- Assert.IsTrue(same.Equals(same2));
- Assert.IsFalse(same.Equals(different));
-
- Assert.IsTrue(same == same2);
- Assert.IsTrue(same != different);
-
- Assert.AreEqual(same.GetHashCode(), same2.GetHashCode());
- Assert.AreNotEqual(same.GetHashCode(), different.GetHashCode());
- }
- }
+namespace bugreport
+{
+ [TestFixture]
+ public class ReportItemTest
+ {
+ [Test]
+ public void Equality()
+ {
+ var same = new ReportItem(123, false);
+ var same2 = new ReportItem(123, false);
+ var different = new ReportItem(456, false);
+
+ Assert.IsTrue(same.Equals(same2));
+ Assert.IsFalse(same.Equals(different));
+
+ Assert.IsTrue(same == same2);
+ Assert.IsTrue(same != different);
+
+ Assert.AreEqual(same.GetHashCode(), same2.GetHashCode());
+ Assert.AreNotEqual(same.GetHashCode(), different.GetHashCode());
+ }
+ }
}
\ No newline at end of file
Modified: SIB.cs
===================================================================
--- SIB.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ SIB.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -20,7 +20,7 @@
"For ModRM that does not specify a SIB, usage of GetBaseRegister is invalid.");
}
- var register = (RegisterName) GetIndexFor(code);
+ var register = (RegisterName)GetIndexFor(code);
if (register == RegisterName.ESP)
{
register = RegisterName.None;
@@ -37,8 +37,8 @@
"For ModRM that does not specify a SIB, usage of GetBaseRegister is invalid.");
}
- var s = (Byte) ((GetSIBFor(code) >> 6) & 3);
- return (UInt32) Math.Pow(2, s);
+ var s = (Byte)((GetSIBFor(code) >> 6) & 3);
+ return (UInt32)Math.Pow(2, s);
}
public static RegisterName GetBaseRegister(Byte[] code)
@@ -50,14 +50,14 @@
}
var sib = GetSIBFor(code);
- var register = (RegisterName) (sib & 7);
+ var register = (RegisterName)(sib & 7);
return register;
}
private static Byte GetIndexFor(Byte[] code)
{
- return (Byte) ((GetSIBFor(code) >> 3) & 7);
+ return (Byte)((GetSIBFor(code) >> 3) & 7);
}
private static Byte GetSIBFor(Byte[] code)
Modified: SIBTests.cs
===================================================================
--- SIBTests.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ SIBTests.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -23,7 +23,7 @@
}
[Test]
- [ExpectedException(typeof (InvalidOperationException))]
+ [ExpectedException(typeof(InvalidOperationException))]
public void GetBaseRegisterWhenNoSIBPresent()
{
// mov ebp,esp
@@ -33,7 +33,7 @@
}
[Test]
- [ExpectedException(typeof (InvalidOperationException))]
+ [ExpectedException(typeof(InvalidOperationException))]
public void GetScaledRegisterWhenNoSIBPresent()
{
// mov ebp,esp
@@ -43,7 +43,7 @@
}
[Test]
- [ExpectedException(typeof (InvalidOperationException))]
+ [ExpectedException(typeof(InvalidOperationException))]
public void GetScalerWhenNoSIBPresent()
{
// mov ebp,esp
@@ -62,7 +62,7 @@
}
[Test]
- [ExpectedException(typeof (InvalidOperationException))]
+ [ExpectedException(typeof(InvalidOperationException))]
public void HasSIBWhenNoModRMPresent()
{
code = new Byte[] {0x00};
Modified: TextUI.csproj
===================================================================
--- TextUI.csproj 2009-09-11 22:28:12 UTC (rev 170)
+++ TextUI.csproj 2009-11-15 00:53:42 UTC (rev 171)
@@ -1,4 +1,5 @@
-<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<ProjectGuid>{53C43EB0-FA91-426B-8239-D14E498B962B}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -17,7 +18,24 @@
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
- <OldToolsVersion>2.0</OldToolsVersion>
+ <OldToolsVersion>3.5</OldToolsVersion>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <PublishUrl>publish\</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Disk</InstallFrom>
+ <UpdateEnabled>false</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <IsWebBootstrapper>false</IsWebBootstrapper>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
+ <TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
@@ -42,6 +60,16 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
+ <CodeAnalysisRuleSet>Migrated rules for AnalysisEngine.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules />
+ <Optimize>true</Optimize>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
+ <CodeAnalysisRuleSet>Migrated rules for TextUI.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules />
+ <Optimize>true</Optimize>
+ </PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="nunit.framework">
@@ -68,4 +96,25 @@
<Name>AnalysisEngine</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="Migrated rules for TextUI.ruleset" />
+ </ItemGroup>
+ <ItemGroup>
+ <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
+ <Visible>False</Visible>
+ <ProductName>Windows Installer 3.1</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ </ItemGroup>
</Project>
\ No newline at end of file
Modified: X86Emulator.cs
===================================================================
--- X86Emulator.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ X86Emulator.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -76,46 +76,7 @@
case OpcodeEncoding.rDX:
case OpcodeEncoding.Iz:
{
- switch (opcode.GetStackEffectFor(code))
- {
- case StackEffect.Pop:
- {
- destinationRegister = opcode.GetDestinationRegisterFor(code);
- state.Registers[destinationRegister] = state.Registers[RegisterName.ESP].PointsTo[0];
- state = state.DoOperation(RegisterName.ESP, OperatorEffect.Sub, new AbstractValue(1));
- break;
- }
-
- case StackEffect.Push:
- {
- state = state.DoOperation(RegisterName.ESP, OperatorEffect.Add, new AbstractValue(1));
-
- if (opcode.HasSourceRegister(code))
- {
- sourceRegister = opcode.GetSourceRegisterFor(code);
- sourceValue = state.Registers[sourceRegister];
- }
- else if (opcode.HasImmediate(code))
- {
- sourceValue = new AbstractValue(opcode.GetImmediateFor(code));
- }
- else
- {
- throw new InvalidOperationException(
- String.Format(
- "tried to push something that wasn't a register or an immediate @ 0x{0:x8}",
- state.InstructionPointer));
- }
-
- state.Registers[RegisterName.ESP].PointsTo[0] = sourceValue;
-
- // TODO(matt_hargett): next step in correct stack emulation,, but breaks PushESPPopESP test
- // state = state.PushOntoStack(sourceValue);
- break;
- }
- }
-
- return state;
+ return emulateStackEffectFor(code, state);
}
case OpcodeEncoding.EvIz:
@@ -233,7 +194,7 @@
var scaledRegisterValue = state.Registers[SIB.GetScaledRegister(code)].Value;
var scaler = SIB.GetScaler(code);
baseRegisterValue = state.Registers[SIB.GetBaseRegister(code)];
- index = (Int32) (scaledRegisterValue * scaler);
+ index = (Int32)(scaledRegisterValue*scaler);
}
else
{
@@ -250,7 +211,7 @@
sourceValue = new AbstractValue(
baseRegisterValue.PointsTo.DoOperation(
OperatorEffect.Add,
- new AbstractValue((UInt32) index)
+ new AbstractValue((UInt32)index)
)
);
@@ -302,7 +263,7 @@
if (!contractSatisfied)
{
- var returnAddress = state.InstructionPointer + (UInt32) code.Length;
+ var returnAddress = state.InstructionPointer + (UInt32)code.Length;
state = state.PushOntoStack(new AbstractValue(returnAddress));
state.InstructionPointer = opcode.GetEffectiveAddress(code, state.InstructionPointer);
}
@@ -331,5 +292,57 @@
}
}
}
+
+ private static MachineState emulateStackEffectFor(byte[] code, MachineState state)
+ {
+ MachineState modifiedState;
+
+ switch (opcode.GetStackEffectFor(code))
+ {
+ case StackEffect.Pop:
+ {
+ var destinationRegister = opcode.GetDestinationRegisterFor(code);
+ state.Registers[destinationRegister] = state.Registers[RegisterName.ESP].PointsTo[0];
+ modifiedState = state.DoOperation(RegisterName.ESP, OperatorEffect.Sub, new AbstractValue(1));
+ break;
+ }
+
+ case StackEffect.Push:
+ {
+ modifiedState = state.DoOperation(RegisterName.ESP, OperatorEffect.Add, new AbstractValue(1));
+
+ AbstractValue sourceValue;
+ if (opcode.HasSourceRegister(code))
+ {
+ var sourceRegister = opcode.GetSourceRegisterFor(code);
+ sourceValue = state.Registers[sourceRegister];
+ }
+ else if (opcode.HasImmediate(code))
+ {
+ sourceValue = new AbstractValue(opcode.GetImmediateFor(code));
+ }
+ else
+ {
+ throw new InvalidOperationException(
+ String.Format(
+ "tried to push something that wasn't a register or an immediate @ 0x{0:x8}",
+ state.InstructionPointer));
+ }
+
+ state.Registers[RegisterName.ESP].PointsTo[0] = sourceValue;
+
+ // TODO(matt_hargett): next step in correct stack emulation,, but breaks PushESPPopESP test
+ // state = state.PushOntoStack(sourceValue);
+ break;
+ }
+
+ default:
+ {
+ throw new InvalidOpcodeException(code);
+ }
+ }
+
+ return modifiedState;
+ }
}
}
\ No newline at end of file
Modified: X86EmulatorTest.cs
===================================================================
--- X86EmulatorTest.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ X86EmulatorTest.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -53,17 +53,7 @@
}
[Test]
- public void AddOneToEAX()
- {
- code = new Byte[] {0x05, 0x01, 0x00, 0x00, 0x00};
- state.Registers[RegisterName.EAX] = new AbstractValue(1);
- state = X86Emulator.Run(reportItems, state, code);
- Assert.AreEqual(code.Length, state.InstructionPointer);
- Assert.AreEqual(0x2, state.Registers[RegisterName.EAX].Value);
- }
-
- [Test]
- [ExpectedException(typeof (InvalidOperationException))]
+ [ExpectedException(typeof(InvalidOperationException))]
public void AddImmediateNonPointerDeref()
{
// add [eax], 0x00
@@ -86,6 +76,17 @@
}
[Test]
+ public void AddOneToEAX()
+ {
+ code = new Byte[] {0x05, 0x01, 0x00, 0x00, 0x00};
+ state.Registers[RegisterName.EAX] = new AbstractValue(1);
+ state = X86Emulator.Run(reportItems, state, code);
+ Assert.AreEqual(code.Length, state.InstructionPointer);
+ Assert.AreEqual(0x2, state.Registers[RegisterName.EAX].Value);
+ }
+
+ [Test]
+ [Ignore("this is the essense of a bug in one of the system tests")]
public void BigComplicatedMuthafuqqa()
{
const byte VALUE = 0xcd;
@@ -174,7 +175,7 @@
}
[Test]
- [ExpectedException(typeof (InvalidOperationException))]
+ [ExpectedException(typeof(InvalidOperationException))]
public void DereferenceRegisterWithNonPointer()
{
// mov eax,DWORD PTR [eax]
@@ -203,7 +204,7 @@
}
[Test]
- [ExpectedException(typeof (ArgumentException))]
+ [ExpectedException(typeof(ArgumentException))]
public void EmptyCodeArray()
{
code = new Byte[] {};
@@ -233,7 +234,7 @@
}
[Test]
- [ExpectedException(typeof (InvalidOpcodeException))]
+ [ExpectedException(typeof(InvalidOpcodeException))]
public void InvalidOpcode()
{
// int3 -- not really invalid, but we probably won't see it in any program we care about
@@ -333,7 +334,7 @@
// mov BYTE PTR [eax+16],bl
const byte OFFSET = 0x10;
state.Registers[RegisterName.EBX] = new AbstractValue(0x1);
- var buffer = AbstractValue.GetNewBuffer((uint) OFFSET + 1);
+ var buffer = AbstractValue.GetNewBuffer((uint)OFFSET + 1);
var pointer = new AbstractValue(buffer);
state.ReturnValue = pointer;
@@ -349,7 +350,7 @@
// mov BYTE PTR [eax+16],bl
const byte OFFSET = 0x10;
state.Registers[RegisterName.EBX] = new AbstractValue(0x1);
- var buffer = AbstractValue.GetNewBuffer((uint) OFFSET + 1);
+ var buffer = AbstractValue.GetNewBuffer((uint)OFFSET + 1);
var pointer = new AbstractValue(buffer);
state.Registers[RegisterName.EAX] = pointer;
@@ -369,19 +370,6 @@
}
[Test]
- public void MovPtrEax16()
- {
- // mov DWORD PTR [eax],0x10
- var value = AbstractValue.GetNewBuffer(1);
- state.Registers[RegisterName.EAX] = new AbstractValue(value);
- code = new Byte[] {0xc7, 0x00, 0x10, 0x00, 0x00, 0x00};
- state = X86Emulator.Run(reportItems, state, code);
-
- var sixteen = state.Registers[RegisterName.EAX].PointsTo[0];
- Assert.AreEqual(0x10, sixteen.Value);
- }
-
- [Test]
public void MovEaxDword()
{
code = new Byte[] {0xb8, 0x37, 0x13, 0x03, 0x00};
@@ -541,6 +529,19 @@
}
[Test]
+ public void MovPtrEax16()
+ {
+ // mov DWORD PTR [eax],0x10
+ var value = AbstractValue.GetNewBuffer(1);
+ state.Registers[RegisterName.EAX] = new AbstractValue(value);
+ code = new Byte[] {0xc7, 0x00, 0x10, 0x00, 0x00, 0x00};
+ state = X86Emulator.Run(reportItems, state, code);
+
+ var sixteen = state.Registers[RegisterName.EAX].PointsTo[0];
+ Assert.AreEqual(0x10, sixteen.Value);
+ }
+
+ [Test]
public void MovPtrEsp16()
{
const byte SIXTEEN = 0x10;
@@ -577,7 +578,7 @@
state = X86Emulator.Run(reportItems, state, code);
Assert.AreEqual(0x804837c, state.InstructionPointer);
- Assert.AreEqual(INITIAL_INSTRUCTION_POINTER + (UInt32) code.Length, state.TopOfStack.Value);
+ Assert.AreEqual(INITIAL_INSTRUCTION_POINTER + (UInt32)code.Length, state.TopOfStack.Value);
}
[Test]
@@ -726,7 +727,7 @@
}
[Test]
- [ExpectedException(typeof (InvalidOperationException))]
+ [ExpectedException(typeof(InvalidOperationException))]
public void SubNonPointerDeref()
{
// sub eax, [eax]
Modified: X86Opcode.cs
===================================================================
--- X86Opcode.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ X86Opcode.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -13,6 +13,8 @@
/// </summary>
public sealed class X86Opcode : Opcode
{
+ #region Opcode Members
+
public OpcodeEncoding GetEncodingFor(Byte[] code)
{
switch (code[0])
@@ -491,8 +493,8 @@
{
var shortCode = new Byte[15];
- var minLength = (Int32) Math.Min(15, code.Length - index);
- Array.ConstrainedCopy(code, (Int32) index, shortCode, 0, minLength);
+ var minLength = (Int32)Math.Min(15, code.Length - index);
+ Array.ConstrainedCopy(code, (Int32)index, shortCode, 0, minLength);
return GetInstructionLengthFor(shortCode);
}
@@ -530,8 +532,10 @@
unchecked
{
// FIXME: find a way to do this without an unchecked operation
- return instructionPointer + offset + (UInt32) code.Length;
+ return instructionPointer + offset + (UInt32)code.Length;
}
}
+
+ #endregion
}
}
\ No newline at end of file
Modified: X86OpcodeTest.cs
===================================================================
--- X86OpcodeTest.cs 2009-09-11 22:28:12 UTC (rev 170)
+++ X86OpcodeTest.cs 2009-11-15 00:53:42 UTC (rev 171)
@@ -251,7 +251,7 @@
}
[Test]
- [ExpectedException(typeof (InvalidOperationException))]
+ [ExpectedException(typeof(InvalidOperationException))]
public void InvalidGetImmediate()
{
code = new Byte[] {0x90};
@@ -539,7 +539,7 @@
}
[Test]
- [ExpectedException(typeof (InvalidOpcodeException))]
+ [ExpectedException(typeof(InvalidOpcodeException))]
public void UnknownOpcode()
{
code = new Byte[] {0xf0, 0x00};
Modified: bugreport.sln
===================================================================
--- bugreport.sln 2009-09-11 22:28:12 UTC (rev 170)
+++ bugreport.sln 2009-11-15 00:53:42 UTC (rev 171)
@@ -1,7 +1,6 @@
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
-# SharpDevelop 3.0.0.3785
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnalysisEngine", "AnalysisEngine.csproj", "{8DC8856B-6FF9-4E39-BF0B-1C1B55115273}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TextUI", "TextUI.csproj", "{53C43EB0-FA91-426B-8239-D14E498B962B}"
Modified: tests/medium/interfunction-taint-parameter.c
===================================================================
--- tests/medium/interfunction-taint-parameter.c 2009-09-11 22:28:12 UTC (rev 170)
+++ tests/medium/interfunction-taint-parameter.c 2009-11-15 00:53:42 UTC (rev 171)
@@ -2,9 +2,9 @@
void bug(char t)
{
- int *array = malloc(0);
+ int *array = malloc(1);
////<exploitable />
- array[0] = t;
+ array[1] = t;
}
int main(int argc, char **argv)
Modified: tests/medium/simple-branch-oob-via-stack-unknown.c
===================================================================
--- tests/medium/simple-branch-oob-via-stack-unknown.c 2009-09-11 22:28:12 UTC (rev 170)
+++ tests/medium/simple-branch-oob-via-stack-unknown.c 2009-11-15 00:53:42 UTC (rev 171)
@@ -7,5 +7,5 @@
void *p = malloc(size + argc);
////<exploitable />
- ((char *)p)[size] = 0;
+ ((char *)p)[size] = **argv;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mat...@us...> - 2009-09-11 22:28:59
|
Revision: 170
http://bugreport.svn.sourceforge.net/bugreport/?rev=170&view=rev
Author: matt_hargett
Date: 2009-09-11 22:28:12 +0000 (Fri, 11 Sep 2009)
Log Message:
-----------
Run ReSharper 5.x alpha code cleanup, which: converted simple properties to auto properties, fixed naming conventions, used objects/array initializers when possible, made use of the var keyword where possible, converted some delegates to lambdas, and other C# 3.0/style cleanups.
Modified Paths:
--------------
AbstractBuffer.cs
AbstractBufferTest.cs
AbstractValue.cs
AbstractValueTest.cs
Analyzer.cs
AnalyzerTest.cs
AssemblyInfo.cs
BitMath.cs
DebuggerCommand.cs
DebuggerView.cs
DumpFileParser.cs
DumpFileParserTest.cs
ElfFileParser.cs
MachineState.cs
MachineStateTest.cs
Main.cs
MainTest.cs
ModRM.cs
ModRMTest.cs
Opcode.cs
OpcodeFormatter.cs
OpcodeFormatterTest.cs
Options.cs
OptionsTest.cs
SIB.cs
X86Emulator.cs
X86EmulatorTest.cs
X86Opcode.cs
X86OpcodeTest.cs
Modified: AbstractBuffer.cs
===================================================================
--- AbstractBuffer.cs 2009-02-12 04:43:29 UTC (rev 169)
+++ AbstractBuffer.cs 2009-09-11 22:28:12 UTC (rev 170)
@@ -10,33 +10,25 @@
{
public sealed class AbstractBuffer
{
- private readonly Int32 allocatedLength;
- private UInt32 baseIndex;
private AbstractValue[] storage;
- public AbstractBuffer(AbstractValue[] _buffer)
+ public AbstractBuffer(AbstractValue[] values)
{
- storage = _buffer;
- allocatedLength = storage.Length;
+ storage = values;
+ Length = storage.Length;
}
- public AbstractBuffer(AbstractBuffer _copyMe)
+ public AbstractBuffer(AbstractBuffer other)
{
- baseIndex = _copyMe.BaseIndex;
- allocatedLength = _copyMe.allocatedLength;
- storage = new AbstractValue[_copyMe.storage.Length];
- Array.Copy(_copyMe.storage, storage, _copyMe.storage.Length);
+ BaseIndex = other.BaseIndex;
+ Length = other.Length;
+ storage = new AbstractValue[other.storage.Length];
+ Array.Copy(other.storage, storage, other.storage.Length);
}
- private UInt32 BaseIndex
- {
- get { return baseIndex; }
- }
+ private UInt32 BaseIndex { get; set; }
- public Int32 Length
- {
- get { return allocatedLength; }
- }
+ public int Length { get; private set; }
public AbstractValue this[Int32 index]
{
@@ -45,38 +37,38 @@
// We check this.storage.Length as well so that we aren't calling Extend() when we dont need to.
if (IsIndexPastBounds(index))
{
- extend(baseIndex + (UInt32) index);
- return storage[baseIndex + index];
+ Extend(BaseIndex + (UInt32) index);
+ return storage[BaseIndex + index];
}
- return storage[baseIndex + index];
+ return storage[BaseIndex + index];
}
set
{
- if ((baseIndex + index) >= allocatedLength)
+ if ((BaseIndex + index) >= Length)
{
- value.IsOOB = true;
+ value.IsOutOfBounds = true;
}
if (IsIndexPastBounds(index))
{
- extend(baseIndex + (UInt32) index);
- storage[baseIndex + index] = value;
+ Extend(BaseIndex + (UInt32) index);
+ storage[BaseIndex + index] = value;
}
else
{
- storage[baseIndex + index] = value;
+ storage[BaseIndex + index] = value;
}
}
}
- public AbstractBuffer DoOperation(OperatorEffect _operatorEffect, AbstractValue _rhs)
+ public AbstractBuffer DoOperation(OperatorEffect operatorEffect, AbstractValue rhs)
{
var lhs = this;
- // TODO: should have a guard for if _rhs isn't a pointer
- switch (_operatorEffect)
+ // TODO: should have a guard for if rhs isn't a pointer
+ switch (operatorEffect)
{
case OperatorEffect.Assignment:
{
@@ -88,7 +80,7 @@
case OperatorEffect.Add:
{
var result = new AbstractBuffer(lhs);
- result.baseIndex += _rhs.Value;
+ result.BaseIndex += rhs.Value;
return result;
}
@@ -97,18 +89,19 @@
{
var result = new AbstractBuffer(lhs);
- if (result.baseIndex < _rhs.Value)
+ if (result.BaseIndex <
+ rhs.Value)
{
throw new ArgumentOutOfRangeException(
String.Format(
"Attempting to set a negative baseindex, baseindex: {0:x4}, _subValue {1:x4}",
- result.baseIndex,
- _rhs.Value
+ result.BaseIndex,
+ rhs.Value
)
);
}
- result.baseIndex -= _rhs.Value;
+ result.BaseIndex -= rhs.Value;
return result;
}
@@ -116,41 +109,44 @@
{
var result = new AbstractBuffer(lhs);
- result.baseIndex &= _rhs.Value;
+ result.BaseIndex &= rhs.Value;
return result;
}
default:
throw new ArgumentException(
- String.Format("Unsupported OperatorEffect: {0}", _operatorEffect), "_operatorEffect");
+ String.Format("Unsupported OperatorEffect: {0}", operatorEffect), "operatorEffect");
}
}
private Boolean IsIndexPastBounds(Int32 index)
{
- return ((baseIndex + index) >= allocatedLength) && ((baseIndex + index) >= storage.Length);
+ return ((BaseIndex + index) >= Length) && ((BaseIndex + index) >= storage.Length);
}
- private void extend(UInt32 _newLength)
+ private void Extend(UInt32 newLength)
{
// Account for element [0] of the array
- _newLength = _newLength + 1;
- if (_newLength >= Length)
+ newLength = newLength + 1;
+ if (newLength >= Length)
{
- var _copyTo = new AbstractValue[_newLength];
+ var extendedCopy = new AbstractValue[newLength];
Int32 i;
for (i = 0; i < storage.Length; i++)
{
- _copyTo[i] = storage[i];
+ extendedCopy[i] = storage[i];
}
- for (; i < _newLength; i++)
+ for (; i < newLength; i++)
{
- _copyTo[i] = new AbstractValue(AbstractValue.UNKNOWN) {IsOOB = true};
+ extendedCopy[i] = new AbstractValue(AbstractValue.UNKNOWN)
+ {
+ IsOutOfBounds = true
+ };
}
- storage = _copyTo;
+ storage = extendedCopy;
}
return;
Modified: AbstractBufferTest.cs
===================================================================
--- AbstractBufferTest.cs 2009-02-12 04:43:29 UTC (rev 169)
+++ AbstractBufferTest.cs 2009-09-11 22:28:12 UTC (rev 170)
@@ -123,7 +123,7 @@
var pointer = new AbstractBuffer(buffer);
var value = pointer[16];
- Assert.IsTrue(value.IsOOB);
+ Assert.IsTrue(value.IsOutOfBounds);
Assert.IsFalse(value.IsInitialized);
Assert.AreEqual(AbstractValue.UNKNOWN, value.Value);
}
@@ -141,13 +141,13 @@
var pointer = new AbstractBuffer(buffer);
// Accessing pointer[2] will cause the AbstractBuffer to extend..
- Assert.IsTrue(pointer[2].IsOOB, " value is not out of bounds");
+ Assert.IsTrue(pointer[2].IsOutOfBounds, " value is not out of bounds");
Assert.IsFalse(pointer[2].IsInitialized);
Assert.AreEqual(AbstractValue.UNKNOWN, pointer[2].Value);
// And then we make sure the in bounds values stay the same
- Assert.IsFalse(pointer[0].IsOOB);
- Assert.IsFalse(pointer[1].IsOOB);
+ Assert.IsFalse(pointer[0].IsOutOfBounds);
+ Assert.IsFalse(pointer[1].IsOutOfBounds);
Assert.AreEqual(0x41, pointer[0].Value);
Assert.AreEqual(0x42, pointer[1].Value);
@@ -160,19 +160,19 @@
var pointer = new AbstractBuffer(buffer);
// Access beyond buffer bounds forcing buffer to expand
- Assert.IsTrue(pointer[17].IsOOB);
+ Assert.IsTrue(pointer[17].IsOutOfBounds);
Assert.IsFalse(pointer[17].IsInitialized);
Assert.AreEqual(AbstractValue.UNKNOWN, pointer[17].Value);
pointer[17] = new AbstractValue(0x41414141);
// Access beyond previously expanded bounds to force 2nd expand
- Assert.IsTrue(pointer[64].IsOOB);
+ Assert.IsTrue(pointer[64].IsOutOfBounds);
Assert.IsFalse(pointer[64].IsInitialized);
Assert.AreEqual(AbstractValue.UNKNOWN, pointer[64].Value);
// check that value set outside of bounds is still the same as well
- Assert.IsTrue(pointer[17].IsOOB);
+ Assert.IsTrue(pointer[17].IsOutOfBounds);
Assert.AreEqual(0x41414141, pointer[17].Value);
}
Modified: AbstractValue.cs
===================================================================
--- AbstractValue.cs 2009-02-12 04:43:29 UTC (rev 169)
+++ AbstractValue.cs 2009-09-11 22:28:12 UTC (rev 170)
@@ -22,48 +22,48 @@
storage = UNKNOWN;
}
- public AbstractValue(AbstractValue[] _willPointTo)
+ public AbstractValue(AbstractValue[] willPointTo)
{
- if (_willPointTo.Length == 0)
+ if (willPointTo.Length == 0)
{
- throw new ArgumentException("Empty buffer is not allowed", "_willPointTo");
+ throw new ArgumentException("Empty buffer is not allowed", "willPointTo");
}
storage = 0xdeadbeef;
- pointsTo = new AbstractBuffer(_willPointTo);
+ pointsTo = new AbstractBuffer(willPointTo);
}
- public AbstractValue(AbstractBuffer _willPointTo)
+ public AbstractValue(AbstractBuffer willPointTo)
{
- if (_willPointTo.Length == 0)
+ if (willPointTo.Length == 0)
{
- throw new ArgumentException("Empty buffer is not allowed", "_willPointTo");
+ throw new ArgumentException("Empty buffer is not allowed", "willPointTo");
}
storage = 0xdeadbeef;
- pointsTo = new AbstractBuffer(_willPointTo);
+ pointsTo = new AbstractBuffer(willPointTo);
}
- public AbstractValue(AbstractValue _copyMe)
+ public AbstractValue(AbstractValue other)
{
- if (_copyMe == null)
+ if (other == null)
{
- throw new ArgumentNullException("_copyMe");
+ throw new ArgumentNullException("other");
}
- storage = _copyMe.Value;
- tainted = _copyMe.IsTainted;
- IsOOB = _copyMe.IsOOB;
+ storage = other.Value;
+ tainted = other.IsTainted;
+ IsOutOfBounds = other.IsOutOfBounds;
- if (_copyMe.PointsTo != null)
+ if (other.PointsTo != null)
{
- pointsTo = new AbstractBuffer(_copyMe.PointsTo);
+ pointsTo = new AbstractBuffer(other.PointsTo);
}
}
- public AbstractValue(UInt32 _value)
+ public AbstractValue(UInt32 value)
{
- storage = _value;
+ storage = value;
}
public AbstractBuffer PointsTo
@@ -78,7 +78,7 @@
private set { tainted = value; }
}
- public Boolean IsOOB { get; set; }
+ public Boolean IsOutOfBounds { get; set; }
public Boolean IsInitialized
{
@@ -122,14 +122,14 @@
}
return Value == other.Value &&
- IsOOB == other.IsOOB &&
+ IsOutOfBounds == other.IsOutOfBounds &&
IsTainted == other.IsTainted &&
PointsTo == other.PointsTo;
}
public override Int32 GetHashCode()
{
- var hashCode = Value.GetHashCode() ^ IsOOB.GetHashCode() ^
+ var hashCode = Value.GetHashCode() ^ IsOutOfBounds.GetHashCode() ^
IsTainted.GetHashCode();
if (PointsTo != null)
@@ -156,7 +156,10 @@
throw new InvalidOperationException("Cannot AddTaint to a pointer");
}
- var taintedValue = new AbstractValue(this) {IsTainted = true};
+ var taintedValue = new AbstractValue(this)
+ {
+ IsTainted = true
+ };
return taintedValue;
}
@@ -189,7 +192,8 @@
const Byte MAXIMUM_DISPLAYED_POINTER_DEPTH = 100;
Int32 count = MAXIMUM_DISPLAYED_POINTER_DEPTH;
- while ((pointer != null) && (count-- > 0))
+ while ((pointer != null) &&
+ (count-- > 0))
{
newResult.Append("*");
Modified: AbstractValueTest.cs
===================================================================
--- AbstractValueTest.cs 2009-02-12 04:43:29 UTC (rev 169)
+++ AbstractValueTest.cs 2009-09-11 22:28:12 UTC (rev 170)
@@ -115,12 +115,15 @@
}
[Test]
- public void OOBSurvivesCopy()
+ public void OutOfBoundsPropertySurvivesCopy()
{
- var src = new AbstractValue(0x31337) {IsOOB = true};
+ var src = new AbstractValue(0x31337)
+ {
+ IsOutOfBounds = true
+ };
var dest = new AbstractValue(src);
- Assert.IsTrue(dest.IsOOB);
+ Assert.IsTrue(dest.IsOutOfBounds);
}
[Test]
@@ -164,12 +167,15 @@
}
[Test]
- public void PreserveIsOOBAfterCopy()
+ public void IsOutOfBoundsPropertySurviviesCopy()
{
- var src = new AbstractValue(0x31337) {IsOOB = true};
+ var src = new AbstractValue(0x31337)
+ {
+ IsOutOfBounds = true
+ };
var dest = new AbstractValue(src);
- Assert.IsTrue(dest.IsOOB);
+ Assert.IsTrue(dest.IsOutOfBounds);
}
[Test]
Modified: Analyzer.cs
===================================================================
--- Analyzer.cs 2009-02-12 04:43:29 UTC (rev 169)
+++ Analyzer.cs 2009-09-11 22:28:12 UTC (rev 170)
@@ -103,17 +103,19 @@
public void Run()
{
- var machineState = new MachineState(getRegistersForLinuxStart());
- machineState.InstructionPointer = parser.EntryPointAddress;
+ var machineState = new MachineState(GetRegistersForLinuxStart())
+ {
+ InstructionPointer = parser.EntryPointAddress
+ };
var instructions = parser.GetBytes();
var index = machineState.InstructionPointer - parser.BaseAddress;
while (index < instructions.Length)
{
var savedState = machineState;
- var instruction = extractInstruction(instructions, index);
+ var instruction = GetInstructionFor(instructions, index);
- machineState = runCode(machineState, instruction);
+ machineState = RunCode(machineState, instruction);
if (null != OnEmulationComplete)
{
OnEmulationComplete(
@@ -129,12 +131,12 @@
}
}
- protected virtual MachineState runCode(MachineState _machineState, Byte[] code)
+ protected virtual MachineState RunCode(MachineState _machineState, Byte[] code)
{
return X86Emulator.Run(reportItems, _machineState, code);
}
- private static RegisterCollection getRegistersForLinuxStart()
+ private static RegisterCollection GetRegistersForLinuxStart()
{
var linuxMainDefaultValues = new RegisterCollection();
@@ -161,9 +163,9 @@
return linuxMainDefaultValues;
}
- private Byte[] extractInstruction(Byte[] instructions, UInt32 index)
+ private Byte[] GetInstructionFor(Byte[] instructions, UInt32 index)
{
- var instructionLength = opcode.GetInstructionLength(instructions, index);
+ var instructionLength = opcode.GetInstructionLengthFor(instructions, index);
var instruction = new Byte[instructionLength];
for (var count = index; count < index + instructionLength; count++)
{
Modified: AnalyzerTest.cs
===================================================================
--- AnalyzerTest.cs 2009-02-12 04:43:29 UTC (rev 169)
+++ AnalyzerTest.cs 2009-09-11 22:28:12 UTC (rev 170)
@@ -27,7 +27,7 @@
}
}
- private IParsable createMockParser(UInt32 expectedReportItemCount)
+ private IParsable CreateMockParser(UInt32 expectedReportItemCount)
{
var control = new DynamicMock(typeof (IParsable));
control.ExpectAndReturn("GetBytes", code, null);
@@ -44,7 +44,7 @@
return control.MockInstance as IParsable;
}
- private class FakeAnalyzer : Analyzer
+ private sealed class FakeAnalyzer : Analyzer
{
private readonly UInt32 actualReportItemCount;
@@ -54,23 +54,23 @@
this.actualReportItemCount = actualReportItemCount;
}
- protected override MachineState runCode(MachineState _machineState, Byte[] _instructionBytes)
+ protected override MachineState RunCode(MachineState machineState, Byte[] instructionBytes)
{
for (UInt32 i = 0; i < actualReportItemCount; i++)
{
ReportItems.Add(new ReportItem(i, false));
}
- _machineState.InstructionPointer += (UInt32) _instructionBytes.Length;
+ machineState.InstructionPointer += (UInt32) instructionBytes.Length;
- return _machineState;
+ return machineState;
}
}
[Test]
public void NoReportItems()
{
- analyzer = new Analyzer(createMockParser(0));
+ analyzer = new Analyzer(CreateMockParser(0));
Assert.AreEqual(0, analyzer.ActualReportItems.Count);
analyzer.Run();
Assert.AreEqual(0, analyzer.ExpectedReportItems.Count);
@@ -87,11 +87,11 @@
[Test]
public void VerifyExpectedAndActualReports()
{
- analyzer = new FakeAnalyzer(createMockParser(2), 2);
+ analyzer = new FakeAnalyzer(CreateMockParser(2), 2);
analyzer.Run();
Assert.AreEqual(analyzer.ActualReportItems.Count, analyzer.ExpectedReportItems.Count);
- analyzer = new FakeAnalyzer(createMockParser(2), 3);
+ analyzer = new FakeAnalyzer(CreateMockParser(2), 3);
analyzer.Run();
Assert.AreNotEqual(analyzer.ActualReportItems.Count, analyzer.ExpectedReportItems.Count);
}
@@ -101,7 +101,7 @@
{
var reportItems = new List<ReportItem>();
- analyzer = new FakeAnalyzer(createMockParser(2), 2);
+ analyzer = new FakeAnalyzer(CreateMockParser(2), 2);
analyzer.OnEmulationComplete +=
delegate(object sender, EmulationEventArgs e)
{
@@ -110,7 +110,7 @@
};
analyzer.OnReport +=
- delegate(object sender, ReportEventArgs e) { reportItems.Add(e.ReportItem); };
+ (sender, e) => reportItems.Add(e.ReportItem);
analyzer.Run();
Assert.AreEqual(2, analyzer.ActualReportItems.Count);
Modified: AssemblyInfo.cs
===================================================================
--- AssemblyInfo.cs 2009-02-12 04:43:29 UTC (rev 169)
+++ AssemblyInfo.cs 2009-09-11 22:28:12 UTC (rev 170)
@@ -8,7 +8,7 @@
using System.Reflection;
using System.Runtime.InteropServices;
-[assembly : ComVisible(false)]
+[assembly: ComVisible(false)]
// The assembly version has following format :
//
@@ -16,5 +16,5 @@
//
// You can specify all values by your own or you can build default build and revision
-[assembly : AssemblyVersion("0.1.*")]
-[assembly : CLSCompliant(true)]
+[assembly: AssemblyVersion("0.1.*")]
+[assembly: CLSCompliant(true)]
\ No newline at end of file
Modified: BitMath.cs
===================================================================
--- BitMath.cs 2009-02-12 04:43:29 UTC (rev 169)
+++ BitMath.cs 2009-09-11 22:28:12 UTC (rev 170)
@@ -13,14 +13,17 @@
public static UInt32 BytesToDword(Byte[] data, Byte index)
{
UInt32 result = 0;
+ const int DWORD_SIZE = 4;
- if (data.Length < index + 4)
+ if (data.Length < index + DWORD_SIZE)
{
throw new ArgumentException(
- String.Format("Not enough bytes for DWORD: need {0}, got {1}", index + 4, data.Length), "data");
+ String.Format("Not enough bytes for DWORD: need {0}, got {1}", index + DWORD_SIZE, data.Length),
+ "data"
+ );
}
- for (Byte i = 0; i < 4; ++i)
+ for (var i = 0; i < DWORD_SIZE; ++i)
{
result |= (UInt32) data[i + index] << (8 * i);
}
Modified: DebuggerCommand.cs
===================================================================
--- DebuggerCommand.cs 2009-02-12 04:43:29 UTC (rev 169)
+++ DebuggerCommand.cs 2009-09-11 22:28:12 UTC (rev 170)
@@ -4,8 +4,6 @@
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
-using System;
-
namespace bugreport
{
public class DebuggerCommand
Modified: DebuggerView.cs
===================================================================
--- DebuggerView.cs 2009-02-12 04:43:29 UTC (rev 169)
+++ DebuggerView.cs 2009-09-11 22:28:12 UTC (rev 170)
@@ -18,22 +18,22 @@
this.interactive = interactive;
}
- public void printInfo(object sender, EmulationEventArgs e)
+ public void PrintInfo(object sender, EmulationEventArgs emulationEvent)
{
- var address = getEffectiveAddressFor(e);
+ var address = GetEffectiveAddressFor(emulationEvent);
Console.Write(address + ":");
Console.Write("\t");
- var code = getCodeFor(e);
- printOpcodeInfo(code);
+ var code = GetCodeFor(emulationEvent);
+ PrintOpcodeInfoFor(code);
Console.WriteLine(state.Registers);
Console.WriteLine();
- handleInputIfNecessary();
+ HandleInputIfNecessary();
}
- private void handleInputIfNecessary()
+ private void HandleInputIfNecessary()
{
if (!interactive) return;
@@ -42,7 +42,7 @@
while (!enterPressed)
{
- var input = getInput();
+ var input = GetInput();
var command = new DebuggerCommand(input);
if (command.IsEnter)
{
@@ -52,15 +52,15 @@
if (command.IsStackPrint)
{
- printStackFor(state);
+ PrintStackFor(state);
continue;
}
if (command.IsDisassemble)
{
var hex = input.Substring("disasm".Length + 1);
- var code = DumpFileParser.getByteArrayFromHexString(hex);
- printOpcodeInfo(code);
+ var code = DumpFileParser.GetByteArrayFor(hex);
+ PrintOpcodeInfoFor(code);
continue;
}
@@ -73,7 +73,7 @@
}
}
- private void printOpcodeInfo(byte[] code)
+ private void PrintOpcodeInfoFor(byte[] code)
{
foreach (var codeByte in code)
{
@@ -97,32 +97,32 @@
Console.Write("\t");
}
- var encoding = OpcodeFormatter.GetEncoding(code);
+ var encoding = OpcodeFormatter.GetEncodingFor(code);
Console.Write("\t");
Console.WriteLine(encoding);
}
- private static Byte[] getCodeFor(EmulationEventArgs e)
+ private static Byte[] GetCodeFor(EmulationEventArgs e)
{
var code = new Byte[e.Code.Count];
e.Code.CopyTo(code, 0);
return code;
}
- private string getEffectiveAddressFor(EmulationEventArgs e)
+ private string GetEffectiveAddressFor(EmulationEventArgs e)
{
state = e.MachineState;
var address = String.Format("{0:x8}", state.InstructionPointer);
return address;
}
- private string getInput()
+ private string GetInput()
{
Console.Write("0x{0:x8} > ", state.InstructionPointer);
return Console.ReadLine();
}
- private static void printStackFor(MachineState state)
+ private static void PrintStackFor(MachineState state)
{
var esp = state.Registers[RegisterName.ESP];
Modified: DumpFileParser.cs
===================================================================
--- DumpFileParser.cs 2009-02-12 04:43:29 UTC (rev 169)
+++ DumpFileParser.cs 2009-09-11 22:28:12 UTC (rev 170)
@@ -23,15 +23,14 @@
Byte[] GetBytes();
}
- public sealed class DumpFileParser : IParsable, IDisposable
+ public sealed class DumpFileParser : IParsable,
+ IDisposable
{
private readonly List<ReportItem> expectedReportItems;
private readonly String functionNameToParse = "main";
private readonly List<Byte[]> opcodeList;
private readonly StreamReader reader;
private readonly Stream stream;
- private UInt32 baseAddress;
- private UInt32 entryPointAddress;
private Boolean inTextSection;
public DumpFileParser(Stream stream, String functionNameToParse)
@@ -41,7 +40,7 @@
this.stream.Position = 0;
reader = new StreamReader(this.stream);
expectedReportItems = new List<ReportItem>();
- opcodeList = parse();
+ opcodeList = Parse();
}
#region IDisposable Members
@@ -63,15 +62,9 @@
get { return expectedReportItems.AsReadOnly(); }
}
- public UInt32 BaseAddress
- {
- get { return baseAddress; }
- }
+ public UInt32 BaseAddress { get; private set; }
- public UInt32 EntryPointAddress
- {
- get { return entryPointAddress; }
- }
+ public UInt32 EntryPointAddress { get; private set; }
public Byte[] GetBytes()
{
@@ -103,7 +96,7 @@
#endregion
- public static Byte[] getByteArrayFromHexString(String hex)
+ public static Byte[] GetByteArrayFor(String hex)
{
var hexStrings = hex.Split(new[] {' '});
@@ -117,13 +110,13 @@
return hexBytes;
}
- private static UInt32 getAddressForLine(String line)
+ private static UInt32 GetAddressFrom(String line)
{
var address = line.Substring(0, 8);
return UInt32.Parse(address, NumberStyles.HexNumber);
}
- private static String getHexWithSpaces(String line)
+ private static String GetHexWithSpacesFrom(String line)
{
var colonIndex = line.IndexOf(':');
@@ -142,7 +135,8 @@
var spaceTabIndex = afterColonToEnd.IndexOf(" \t", StringComparison.Ordinal);
Int32 endOfHexIndex;
- if (doubleSpaceIndex >= 0 && spaceTabIndex >= 0)
+ if (doubleSpaceIndex >= 0 &&
+ spaceTabIndex >= 0)
{
endOfHexIndex = doubleSpaceIndex < spaceTabIndex ? doubleSpaceIndex : spaceTabIndex;
}
@@ -161,31 +155,31 @@
return hexString;
}
- private static Byte[] getHexFromString(String line)
+ private static Byte[] GetHexFrom(String line)
{
if (line.Trim().Length == 0)
{
return null;
}
- var hex = getHexWithSpaces(line);
+ var hex = GetHexWithSpacesFrom(line);
if (null == hex)
{
return null;
}
- var hexBytes = getByteArrayFromHexString(hex);
+ var hexBytes = GetByteArrayFor(hex);
return hexBytes;
}
- private static Boolean hasAnnotation(String line)
+ private static Boolean HasAnnotation(String line)
{
return line.Contains("//<OutOfBoundsMemoryAccess ");
}
- private static ReportItem getAnnotation(String line)
+ private static ReportItem GetAnnotationFrom(String line)
{
var locationIndex = line.IndexOf("=", StringComparison.Ordinal) + 1;
var location = UInt32.Parse(line.Substring(locationIndex + "/>".Length, 8), NumberStyles.HexNumber);
@@ -195,43 +189,47 @@
return new ReportItem(location, exploitable);
}
- private void updateMainInfo(String line)
+ private void UpdateMainInfoFrom(String line)
{
- if (String.IsNullOrEmpty(line) || line[0] < '0' || line[0] > '7') return;
+ if (String.IsNullOrEmpty(line) || line[0] < '0' ||
+ line[0] > '7')
+ {
+ return;
+ }
if (line.Contains("<_start>:"))
{
- baseAddress = getAddressForLine(line);
+ BaseAddress = GetAddressFrom(line);
inTextSection = true;
}
if (line.Contains("<" + functionNameToParse + ">:"))
{
- entryPointAddress = getAddressForLine(line);
+ EntryPointAddress = GetAddressFrom(line);
}
}
- private List<Byte[]> parse()
+ private List<Byte[]> Parse()
{
var opcodes = new List<Byte[]>();
while (!reader.EndOfStream)
{
var currentLine = reader.ReadLine();
- if (hasAnnotation(currentLine))
+ if (HasAnnotation(currentLine))
{
- var item = getAnnotation(currentLine);
+ var item = GetAnnotationFrom(currentLine);
expectedReportItems.Add(item);
}
- updateMainInfo(currentLine);
+ UpdateMainInfoFrom(currentLine);
if (inTextSection)
{
- var opcode = getHexFromString(currentLine);
+ var opcode = GetHexFrom(currentLine);
if (opcode != null)
{
- opcodes.Add(getHexFromString(currentLine));
+ opcodes.Add(GetHexFrom(currentLine));
}
}
}
Modified: DumpFileParserTest.cs
===================================================================
--- DumpFileParserTest.cs 2009-02-12 04:43:29 UTC (rev 169)
+++ DumpFileParserTest.cs 2009-09-11 22:28:12 UTC (rev 170)
@@ -27,7 +27,10 @@
[TearDown]
public void TearDown()
{
- if (parser == null) return;
+ if (parser == null)
+ {
+ return;
+ }
parser.Dispose();
parser = null;
@@ -37,16 +40,12 @@
[TestFixture]
public class WithNothingElseTest : DumpFileParserFixture
{
- #region Setup/Teardown
-
[SetUp]
public override void SetUp()
{
base.SetUp();
}
- #endregion
-
[Test]
public void EmptyLine()
{
Modified: ElfFileParser.cs
===================================================================
--- ElfFileParser.cs 2009-02-12 04:43:29 UTC (rev 169)
+++ ElfFileParser.cs 2009-09-11 22:28:12 UTC (rev 170)
@@ -11,7 +11,8 @@
namespace bugreport
{
- public sealed class ElfFileParser : IParsable, IDisposable
+ public sealed class ElfFileParser : IParsable,
+ IDisposable
{
private readonly Stream stream;
private readonly Byte[] textData;
@@ -22,8 +23,6 @@
textData = new Byte[stream.Length];
}
- #region IDisposable Members
-
public void Dispose()
{
if (null != stream)
@@ -32,10 +31,6 @@
}
}
- #endregion
-
- #region IParsable Members
-
public UInt32 BaseAddress
{
get { return 0x080482e0; }
@@ -57,7 +52,5 @@
stream.Read(textData, 0, (Int32) (stream.Length - stream.Position));
return textData;
}
-
- #endregion
}
}
\ No newline at end of file
Modified: MachineState.cs
===================================================================
--- MachineState.cs 2009-02-12 04:43:29 UTC (rev 169)
+++ MachineState.cs 2009-09-11 22:28:12 UTC (rev 170)
@@ -169,21 +169,21 @@
return newState;
}
- public MachineState DoOperation(OperatorEffect _operatorEffect, AbstractValue _offset)
+ public MachineState DoOperation(OperatorEffect operatorEffect, AbstractValue offset)
{
- if (_offset.IsPointer)
+ if (offset.IsPointer)
{
throw new ArgumentException("_offset pointer not supported.");
}
var newState = new MachineState(this);
- switch (_operatorEffect)
+ switch (operatorEffect)
{
case OperatorEffect.Jnz:
{
if (!newState.zeroFlag)
{
- newState.instructionPointer += _offset.Value;
+ newState.instructionPointer += offset.Value;
}
break;
@@ -192,23 +192,23 @@
default:
{
throw new ArgumentException(
- String.Format("Unsupported OperatorEffect: {0}", _operatorEffect), "_operatorEffect");
+ String.Format("Unsupported OperatorEffect: {0}", operatorEffect), "operatorEffect");
}
}
return newState;
}
- public MachineState DoOperation(UInt32 offset, OperatorEffect _operatorEffect, AbstractValue rhs)
+ public MachineState DoOperation(UInt32 offset, OperatorEffect operatorEffect, AbstractValue rhs)
{
var newState = new MachineState(this);
- switch (_operatorEffect)
+ switch (operatorEffect)
{
case OperatorEffect.Assignment:
{
newState.dataSegment[offset] =
- DoOperation(newState.dataSegment[offset], _operatorEffect, rhs).Value;
+ DoOperation(newState.dataSegment[offset], operatorEffect, rhs).Value;
break;
}
}
@@ -216,16 +216,16 @@
return newState;
}
- public MachineState DoOperation(RegisterName lhs, Int32 index, OperatorEffect _operatorEffect, AbstractValue rhs)
+ public MachineState DoOperation(RegisterName lhs, Int32 index, OperatorEffect operatorEffect, AbstractValue rhs)
{
var newState = new MachineState(this);
- switch (_operatorEffect)
+ switch (operatorEffect)
{
case OperatorEffect.Assignment:
case OperatorEffect.Cmp:
{
- var result = DoOperation(Registers[lhs].PointsTo[index], _operatorEffect, rhs);
+ var result = DoOperation(Registers[lhs].PointsTo[index], operatorEffect, rhs);
newState.Registers[lhs].PointsTo[index] = result.Value;
newState.ZeroFlag = result.ZeroFlag;
break;
@@ -235,18 +235,19 @@
return newState;
}
- public MachineState DoOperation(RegisterName lhs, OperatorEffect _operatorEffect, AbstractValue rhs)
+ public MachineState DoOperation(RegisterName lhs, OperatorEffect operatorEffect, AbstractValue rhs)
{
var newState = new MachineState(this);
- if (Registers[lhs].IsPointer && _operatorEffect != OperatorEffect.Assignment)
+ if (Registers[lhs].IsPointer &&
+ operatorEffect != OperatorEffect.Assignment)
{
- var newBuffer = Registers[lhs].PointsTo.DoOperation(_operatorEffect, rhs);
+ var newBuffer = Registers[lhs].PointsTo.DoOperation(operatorEffect, rhs);
newState.Registers[lhs] = new AbstractValue(newBuffer);
}
else
{
- var result = DoOperation(Registers[lhs], _operatorEffect, rhs);
+ var result = DoOperation(Registers[lhs], operatorEffect, rhs);
newState.Registers[lhs] = result.Value;
newState.ZeroFlag = result.ZeroFlag;
}
@@ -254,18 +255,19 @@
return newState;
}
- public MachineState DoOperation(RegisterName lhs, OperatorEffect _operatorEffect, RegisterName rhs)
+ public MachineState DoOperation(RegisterName lhs, OperatorEffect operatorEffect, RegisterName rhs)
{
var newState = new MachineState(this);
- var result = DoOperation(Registers[lhs], _operatorEffect, Registers[rhs]);
+ var result = DoOperation(Registers[lhs], operatorEffect, Registers[rhs]);
newState.Registers[lhs] = result.Value;
newState.ZeroFlag = result.ZeroFlag;
return newState;
}
- private static OperationResult DoOperation(AbstractValue lhs, OperatorEffect _operatorEffect, AbstractValue rhs)
+ private static OperationResult DoOperation(AbstractValue lhs, OperatorEffect operatorEffect, AbstractValue rhs)
{
- if (rhs.IsPointer && _operatorEffect != OperatorEffect.Assignment)
+ if (rhs.IsPointer &&
+ operatorEffect != OperatorEffect.Assignment)
{
throw new ArgumentException("rhs pointer only supported for OperatorEffect.Assignment.");
}
@@ -273,12 +275,13 @@
var result = new OperationResult();
AbstractValue totalValue;
- if (_operatorEffect == OperatorEffect.Assignment)
+ if (operatorEffect == OperatorEffect.Assignment)
{
var newValue = new AbstractValue(rhs);
- if (rhs.IsInitialized && rhs.IsOOB)
+ if (rhs.IsInitialized &&
+ rhs.IsOutOfBounds)
{
- newValue.IsOOB = true;
+ newValue.IsOutOfBounds = true;
}
result.Value = newValue;
@@ -286,7 +289,7 @@
return result;
}
- if (_operatorEffect == OperatorEffect.Cmp)
+ if (operatorEffect == OperatorEffect.Cmp)
{
result.ZeroFlag = (lhs.Value - rhs.Value) == 0;
@@ -297,15 +300,16 @@
if (lhs.IsPointer)
{
- var newBuffer = lhs.PointsTo.DoOperation(_operatorEffect, rhs);
+ var newBuffer = lhs.PointsTo.DoOperation(operatorEffect, rhs);
result.Value = new AbstractValue(newBuffer);
return result;
}
- var total = getCalculatedValue(lhs.Value, _operatorEffect, rhs.Value);
+ var total = CalculateValueFor(lhs.Value, operatorEffect, rhs.Value);
totalValue = new AbstractValue(total);
- if (lhs.IsTainted || rhs.IsTainted)
+ if (lhs.IsTainted ||
+ rhs.IsTainted)
{
totalValue = totalValue.AddTaint();
}
@@ -314,7 +318,7 @@
return result;
}
- private static UInt32 getCalculatedValue(UInt32 lhs, OperatorEffect operatorEffect, UInt32 rhs)
+ private static UInt32 CalculateValueFor(UInt32 lhs, OperatorEffect operatorEffect, UInt32 rhs)
{
switch (operatorEffect)
{
Modified: MachineStateTest.cs
===================================================================
--- MachineStateTest.cs 2009-02-12 04:43:29 UTC (rev 169)
+++ MachineStateTest.cs 2009-09-11 22:28:12 UTC (rev 170)
@@ -75,10 +75,13 @@
[Test]
public void AssignmentRetainsOOB()
{
- var oob = new AbstractValue(1) {IsOOB = true};
+ var oob = new AbstractValue(1)
+ {
+ IsOutOfBounds = true
+ };
state = state.DoOperation(RegisterName.EAX, OperatorEffect.Assignment, oob);
- Assert.IsTrue(eax.IsOOB);
+ Assert.IsTrue(eax.IsOutOfBounds);
}
[Test]
@@ -258,6 +261,18 @@
}
[Test]
+ public void PushTwiceThenManuallyAdjustStackThenAssignToEbp()
+ {
+ AbstractValue[] buffer = AbstractValue.GetNewBuffer(0x20);
+ esp = new AbstractValue(buffer);
+ state = state.PushOntoStack(one);
+ state = state.PushOntoStack(two);
+
+ state = state.DoOperation(RegisterName.ESP, OperatorEffect.Sub, new AbstractValue(0x4));
+ Assert.AreEqual(one, state.TopOfStack);
+ }
+
+ [Test]
public void Shr()
{
eax = new AbstractValue(0x8).AddTaint();
Modified: Main.cs
===================================================================
--- Main.cs 2009-02-12 04:43:29 UTC (rev 169)
+++ Main.cs 2009-09-11 22:28:12 UTC (rev 170)
@@ -21,18 +21,18 @@
if (arguments.Length < 1)
{
- printUsage();
+ PrintUsage();
return;
}
try
{
- Options.ParseArguments(arguments);
+ Options.ParseArgumentsFrom(arguments);
}
catch (ArgumentException e)
{
Console.WriteLine(e.Message);
- printUsage();
+ PrintUsage();
Environment.Exit(1);
}
@@ -42,7 +42,7 @@
Environment.Exit(1);
}
- analyzeFiles(Options.Filenames, Options.IsTracing, Options.IsDebugging);
+ AnalyzeFiles(Options.Filenames, Options.IsTracing, Options.IsDebugging);
if (analyzer.ExpectedReportItems.Count == 0 ||
(analyzer.ExpectedReportItems.Count == analyzer.ActualReportItems.Count))
@@ -56,9 +56,9 @@
Environment.Exit(2);
}
- private static void analyzeFiles(IEnumerable<string> _fileNames, Boolean _isTracing, Boolean _isDebugging)
+ private static void AnalyzeFiles(IEnumerable<string> fileNames, Boolean withTracing, Boolean withDebugging)
{
- foreach (var fileName in _fileNames)
+ foreach (var fileName in fileNames)
{
Console.WriteLine();
Console.WriteLine("Interpreting file: " + fileName);
@@ -80,18 +80,18 @@
IParsable parser = new ElfFileParser(fileStream);
analyzer = new Analyzer(parser);
- analyzer.OnReport += printReportItem;
+ analyzer.OnReport += PrintReportItem;
- if (_isTracing)
+ if (withTracing)
{
- analyzer.OnEmulationComplete += new DebuggerView(_isDebugging).printInfo;
+ analyzer.OnEmulationComplete += new DebuggerView(withDebugging).PrintInfo;
}
analyzer.Run();
}
}
- private static void printReportItem(object sender, ReportEventArgs e)
+ private static void PrintReportItem(object sender, ReportEventArgs e)
{
var item = e.ReportItem;
@@ -106,7 +106,7 @@
Console.WriteLine();
}
- private static void printUsage()
+ private static void PrintUsage()
{
Console.WriteLine("Usage: bugreport.exe [--trace] file.test");
}
Modified: MainTest.cs
===================================================================
--- MainTest.cs 2009-02-12 04:43:29 UTC (rev 169)
+++ MainTest.cs 2009-09-11 22:28:12 UTC (rev 170)
@@ -22,7 +22,7 @@
private readonly String testRoot = Directory.GetCurrentDirectory() + @"/../../tests/simple/heap/";
private readonly String testDataFile = Directory.GetCurrentDirectory() + @"/../../systemTestsList.txt";
- private static void waitForAnalysisToFinish(Process analysisProcess)
+ private static void WaitForAnalysisToFinish(Process analysisProcess)
{
var maximumTimeAllowed = TimeSpan.FromSeconds(10);
while (!analysisProcess.HasExited && (DateTime.Now - analysisProcess.StartTime < maximumTimeAllowed))
@@ -31,7 +31,7 @@
}
}
- private static List<String> getOutputFromAnalysis(Process analysisProcess)
+ private static List<String> GetOutputFrom(Process analysisProcess)
{
var messages = new List<String>();
@@ -46,26 +46,31 @@
return messages;
}
- private static Process getAnalysisProcessForFileName(String fileName)
+ private static Process GetAnalysisProcessFor(String fileName)
{
- var analysisProcess = new Process();
- analysisProcess.StartInfo.FileName = "bugreport.exe";
- analysisProcess.StartInfo.Arguments = "\"" + fileName + "\"";
- analysisProcess.StartInfo.RedirectStandardOutput = true;
- analysisProcess.StartInfo.UseShellExecute = false;
- analysisProcess.StartInfo.CreateNoWindow = false;
+ var analysisProcess = new Process
+ {
+ StartInfo =
+ {
+ FileName = "bugreport.exe",
+ Arguments = "\"" + fileName + "\"",
+ RedirectStandardOutput = true,
+ UseShellExecute = false,
+ CreateNoWindow = false
+ }
+ };
return analysisProcess;
}
- private static List<String> getOutputForFilename(String fileName)
+ private static List<String> GetOutputFor(String fileName)
{
- var analysisProcess = getAnalysisProcessForFileName(fileName);
+ var analysisProcess = GetAnalysisProcessFor(fileName);
analysisProcess.Start();
- waitForAnalysisToFinish(analysisProcess);
+ WaitForAnalysisToFinish(analysisProcess);
- return getOutputFromAnalysis(analysisProcess);
+ return GetOutputFrom(analysisProcess);
}
[Test]
@@ -88,7 +93,7 @@
Assert.IsTrue(File.Exists(fileName), fileName + " does not exist. Fix paths in test data?");
- var messages = getOutputForFilename(fileName);
+ var messages = GetOutputFor(fileName);
try
{
Modified: ModRM.cs
===================================================================
--- ModRM.cs 2009-02-12 04:43:29 UTC (rev 169)
+++ ModRM.cs 2009-09-11 22:28:12 UTC (rev 170)
@@ -12,60 +12,60 @@
{
private static readonly Opcode opcode = new X86Opcode();
- private static Byte GetRM(Byte modrm)
+ private static Byte GetRMFor(Byte modrm)
{
return (Byte) (modrm & 7);
}
- public static RegisterName GetEv(Byte[] code)
+ public static RegisterName GetEvFor(Byte[] code)
{
if (HasSIB(code))
{
throw new InvalidOperationException("For ModRM that specifies SIB byte, usage of GetEv is invalid.");
}
- var modRM = getModRM(code);
+ var modRM = GetModRMFor(code);
return (RegisterName) (modRM & 7);
}
- internal static RegisterName GetGv(Byte[] code)
+ internal static RegisterName GetGvFor(Byte[] code)
{
- var modRM = getModRM(code);
+ var modRM = GetModRMFor(code);
return (RegisterName) ((modRM >> 3) & 7);
}
- internal static Byte GetOpcodeGroupIndex(Byte[] _code)
+ internal static Byte GetOpcodeGroupIndexFor(Byte[] code)
{
- var modRM = getModRM(_code);
+ var modRM = GetModRMFor(code);
return (Byte) ((modRM >> 3) & 7);
}
- public static Boolean HasIndex(Byte[] _code)
+ public static Boolean HasIndex(Byte[] code)
{
- var modRM = getModRM(_code);
- var mod = getMod(modRM);
+ var modRM = GetModRMFor(code);
+ var mod = GetModFor(modRM);
return mod == 1 || mod == 2;
}
- public static Byte GetIndex(Byte[] _code)
+ public static Byte GetIndexFor(Byte[] code)
{
- if (!HasIndex(_code))
+ if (!HasIndex(code))
{
throw new InvalidOperationException(
- "For ModRM that does not specify an index, usage of GetIndex is invalid."
+ "For ModRM that does not specify an index, usage of GetIndexFor is invalid."
);
}
- UInt32 modRMIndex = opcode.GetOpcodeLength(_code);
- var modRM = getModRM(_code);
- var mod = getMod(modRM);
+ UInt32 modRMIndex = opcode.GetOpcodeLengthFor(code);
+ var modRM = GetModRMFor(code);
+ var mod = GetModFor(modRM);
switch (mod)
{
case 1:
{
- return _code[modRMIndex + 1];
+ return code[modRMIndex + 1];
}
default:
@@ -75,43 +75,44 @@
}
}
- public static Boolean IsEffectiveAddressDereferenced(Byte[] _code)
+ public static Boolean IsEffectiveAddressDereferenced(Byte[] code)
{
- var modRM = getModRM(_code);
+ var modRM = GetModRMFor(code);
- return !(getMod(modRM) == 3);
+ return !(GetModFor(modRM) == 3);
}
- public static Boolean HasOffset(Byte[] _code)
+ public static Boolean HasOffset(Byte[] code)
{
- if (HasSIB(_code))
+ if (HasSIB(code))
{
return false;
}
- var modRM = getModRM(_code);
- return GetRM(modRM) == 5 && getMod(modRM) == 0;
+ var modRM = GetModRMFor(code);
+ return GetRMFor(modRM) == 5 && GetModFor(modRM) == 0;
}
- public static UInt32 GetOffset(Byte[] code)
+ public static UInt32 GetOffsetFor(Byte[] code)
{
- var offsetBeginsAt = opcode.GetOpcodeLength(code);
+ var offsetBeginsAt = opcode.GetOpcodeLengthFor(code);
offsetBeginsAt++; // for modRM byte
return BitMath.BytesToDword(code, offsetBeginsAt);
}
- public static Boolean HasSIB(Byte[] _code)
+ public static Boolean HasSIB(Byte[] code)
{
- var modRM = getModRM(_code);
+ var modRM = GetModRMFor(code);
- return GetRM(modRM) == 4 && IsEffectiveAddressDereferenced(_code);
+ return GetRMFor(modRM) == 4 && IsEffectiveAddressDereferenced(code);
}
public static Boolean IsEvDword(Byte[] code)
{
- var modRM = getModRM(code);
- if ((getMod(modRM) == 0) && (GetRM(modRM) == 5))
+ var modRM = GetModRMFor(code);
+ if ((GetModFor(modRM) == 0) &&
+ (GetRMFor(modRM) == 5))
{
return true;
}
@@ -119,19 +120,19 @@
return false;
}
- private static Byte getModRM(Byte[] _code)
+ private static Byte GetModRMFor(Byte[] code)
{
- Int32 modRMIndex = opcode.GetOpcodeLength(_code);
+ Int32 modRMIndex = opcode.GetOpcodeLengthFor(code);
- if (modRMIndex > _code.Length - 1)
+ if (modRMIndex > code.Length - 1)
{
- throw new InvalidOperationException("No ModRM present: " + _code[0]);
+ throw new InvalidOperationException("No ModRM present: " + code[0]);
}
- return _code[modRMIndex];
+ return code[modRMIndex];
}
- private static Byte getMod(Byte modrm)
+ private static Byte GetModFor(Byte modrm)
{
return (Byte) ((modrm >> 6) & 3);
}
Modified: ModRMTest.cs
===================================================================
--- ModRMTest.cs 2009-02-12 04:43:29 UTC (rev 169)
+++ ModRMTest.cs 2009-09-11 22:28:12 UTC (rev 170)
@@ -19,8 +19,8 @@
{
// mov eax,DWORD PTR [eax]
code = new Byte[] {0x8b, 0x00};
- Assert.AreEqual(RegisterName.EAX, ModRM.GetEv(code));
- Assert.AreEqual(RegisterName.EAX, ModRM.GetGv(code));
+ Assert.AreEqual(RegisterName.EAX, ModRM.GetEvFor(code));
+ Assert.AreEqual(RegisterName.EAX, ModRM.GetGvFor(code));
Assert.IsFalse(ModRM.HasIndex(code));
Assert.IsTrue(ModRM.IsEffectiveAddressDereferenced(code));
}
@@ -29,21 +29,21 @@
[ExpectedException(typeof (NotImplementedException))]
public void EaxEbpPlusDword12()
{
- var index = 0x0c;
- code = new Byte[] {0x8b, 0x85, (Byte) index, 0x00, 0x00, 0x00};
+ const int INDEX = 0x0c;
+ code = new Byte[] {0x8b, 0x85, INDEX, 0x00, 0x00, 0x00};
Assert.IsTrue(ModRM.HasIndex(code));
- Assert.AreEqual(index, ModRM.GetIndex(code));
+ Assert.AreEqual(INDEX, ModRM.GetIndexFor(code));
}
[Test]
public void EaxEbpPlusSByte12()
{
// mov eax,DWORD PTR [ebp+index]
- var index = 0x0c;
- code = new Byte[] {0x8b, 0x45, (Byte) index};
- Assert.AreEqual(RegisterName.EBP, ModRM.GetEv(code));
- Assert.AreEqual(RegisterName.EAX, ModRM.GetGv(code));
- Assert.AreEqual(index, ModRM.GetIndex(code));
+ const int INDEX = 0x0c;
+ code = new Byte[] {0x8b, 0x45, INDEX};
+ Assert.AreEqual(RegisterName.EBP, ModRM.GetEvFor(code));
+ Assert.AreEqual(RegisterName.EAX, ModRM.GetGvFor(code));
+ Assert.AreEqual(INDEX, ModRM.GetIndexFor(code));
}
[Test]
@@ -51,9 +51,9 @@
{
// mov eax,DWORD PTR [ebx-4]
code = new Byte[] {0x8b, 0x43, 0xfc};
- Assert.AreEqual(RegisterName.EBX, ModRM.GetEv(code));
- Assert.AreEqual(RegisterName.EAX, ModRM.GetGv(code));
- Assert.AreEqual(0xfc, ModRM.GetIndex(code));
+ Assert.AreEqual(RegisterName.EBX, ModRM.GetEvFor(code));
+ Assert.AreEqual(RegisterName.EAX, ModRM.GetGvFor(code));
+ Assert.AreEqual(0xfc, ModRM.GetIndexFor(code));
}
[Test]
@@ -61,10 +61,10 @@
{
// mov ebx,DWORD PTR [ebp-12]
code = new Byte[] {0x8b, 0x5d, 0xf4};
- Assert.AreEqual(RegisterName.EBP, ModRM.GetEv(code));
- Assert.AreEqual(RegisterName.EBX, ModRM.GetGv(code));
+ Assert.AreEqual(RegisterName.EBP, ModRM.GetEvFor(code));
+ Assert.AreEqual(RegisterName.EBX, ModRM.GetGvFor(code));
Assert.IsFalse(ModRM.HasSIB(code));
- Assert.AreEqual(0xf4, ModRM.GetIndex(code));
+ Assert.AreEqual(0xf4, ModRM.GetIndexFor(code));
}
[Test]
@@ -72,9 +72,9 @@
{
// mov ebx,DWORD PTR [esp]
code = new Byte[] {0x8b, 0x1c, 0x24};
- //// Assert.AreEqual(RegisterName.ESP, ModRM.GetEv(code));
+ //// Assert.AreEqual(RegisterName.ESP, ModRM.GetEvFor(code));
Assert.IsTrue(ModRM.HasSIB(code));
- Assert.AreEqual(RegisterName.EBX, ModRM.GetGv(code));
+ Assert.AreEqual(RegisterName.EBX, ModRM.GetGvFor(code));
Assert.IsFalse(ModRM.HasIndex(code));
}
@@ -83,9 +83,9 @@
{
// mov edi,DWORD PTR [ebp-4]
code = new Byte[] {0x8b, 0x7d, 0xfc};
- Assert.AreEqual(RegisterName.EBP, ModRM.GetEv(code));
- Assert.AreEqual(RegisterName.EDI, ModRM.GetGv(code));
- Assert.AreEqual(0xfc, ModRM.GetIndex(code));
+ Assert.AreEqual(RegisterName.EBP, ModRM.GetEvFor(code));
+ Assert.AreEqual(RegisterName.EDI, ModRM.GetGvFor(code));
+ Assert.AreEqual(0xfc, ModRM.GetIndexFor(code));
}
[Test]
@@ -93,9 +93,9 @@
{
// mov esi,DWORD PTR [ebp-8]
code = new Byte[] {0x8b, 0x75, 0xf8};
- Assert.AreEqual(RegisterName.EBP, ModRM.GetEv(code));
- Assert.AreEqual(RegisterName.ESI, ModRM.GetGv(code));
- Assert.AreEqual(0xf8, ModRM.GetIndex(code));
+ Assert.AreEqual(RegisterName.EBP, ModRM.GetEvFor(code));
+ Assert.AreEqual(RegisterName.ESI, ModRM.GetGvFor(code));
+ Assert.AreEqual(0xf8, ModRM.GetIndexFor(code));
}
[Test]
@@ -104,7 +104,7 @@
{
code = new Byte[] {0xc7, 0x04, 0x24, 0x10, 0x00, 0x00, 0x00};
Assert.IsTrue(ModRM.HasSIB(code));
- ModRM.GetEv(code);
+ ModRM.GetEvFor(code);
}
[Test]
@@ -113,7 +113,7 @@
{
code = new Byte[] {0x89, 0xe5};
Assert.IsFalse(ModRM.HasIndex(code));
- ModRM.GetIndex(code);
+ ModRM.GetIndexFor(code);
}
[Test]
@@ -121,7 +1...
[truncated message content] |
|
From: NecDel <nec...@gm...> - 2009-08-06 21:51:54
|
Anyone have an example solution to this thing? I have been fighting this thing forever trying to get my format string to overwrite an address but can not get anything to happen? I am reversing my string and everything looks good to me but I get no results? Any help would be great. |
|
From: <mat...@us...> - 2009-02-12 04:44:08
|
Revision: 169
http://bugreport.svn.sourceforge.net/bugreport/?rev=169&view=rev
Author: matt_hargett
Date: 2009-02-12 04:43:29 +0000 (Thu, 12 Feb 2009)
Log Message:
-----------
oopz, forgot to add the new gendarme files. also adding the fxcop ruleset.
Added Paths:
-----------
bugreport.FxCop
lib/gendarme/AUTHORS
lib/gendarme/Gendarme.Framework.pdb
lib/gendarme/Gendarme.Rules.BadPractice.dll
lib/gendarme/Gendarme.Rules.BadPractice.pdb
lib/gendarme/Gendarme.Rules.Concurrency.pdb
lib/gendarme/Gendarme.Rules.Correctness.pdb
lib/gendarme/Gendarme.Rules.Design.Generic.dll
lib/gendarme/Gendarme.Rules.Design.Linq.dll
lib/gendarme/Gendarme.Rules.Design.dll
lib/gendarme/Gendarme.Rules.Design.pdb
lib/gendarme/Gendarme.Rules.Exceptions.pdb
lib/gendarme/Gendarme.Rules.Interoperability.dll
lib/gendarme/Gendarme.Rules.Interoperability.pdb
lib/gendarme/Gendarme.Rules.Maintainability.dll
lib/gendarme/Gendarme.Rules.Naming.dll
lib/gendarme/Gendarme.Rules.Naming.pdb
lib/gendarme/Gendarme.Rules.Performance.pdb
lib/gendarme/Gendarme.Rules.Portability.pdb
lib/gendarme/Gendarme.Rules.Security.Cas.dll
lib/gendarme/Gendarme.Rules.Security.pdb
lib/gendarme/Gendarme.Rules.Serialization.dll
lib/gendarme/Gendarme.Rules.Serialization.pdb
lib/gendarme/Gendarme.Rules.Smells.dll
lib/gendarme/Gendarme.Rules.Smells.pdb
lib/gendarme/Gendarme.Rules.Ui.pdb
lib/gendarme/ICSharpCode.SharpZipLib.dll
lib/gendarme/MIT.X11
lib/gendarme/Mono.Cecil.Mdb.dll
lib/gendarme/Mono.Cecil.Pdb.dll
lib/gendarme/Mono.Cecil.Pdb.pdb
lib/gendarme/Mono.Cecil.pdb
lib/gendarme/NEWS
lib/gendarme/README
lib/gendarme/gendarme-wizard.exe
lib/gendarme/gendarme.1
lib/gendarme/gendarme.pdb
lib/gendarme/self-test.ignore
Added: bugreport.FxCop
===================================================================
--- bugreport.FxCop (rev 0)
+++ bugreport.FxCop 2009-02-12 04:43:29 UTC (rev 169)
@@ -0,0 +1,254 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FxCopProject Version="1.36" Name="My FxCop Project">
+ <ProjectOptions>
+ <SharedProject>True</SharedProject>
+ <Stylesheet Apply="False">c:\program files\microsoft fxcop 1.36\Xml\FxCopReport.xsl</Stylesheet>
+ <SaveMessages>
+ <Project Status="Active, Excluded" NewOnly="False" />
+ <Report Status="Active" NewOnly="False" />
+ </SaveMessages>
+ <ProjectFile Compress="True" DefaultTargetCheck="True" DefaultRuleCheck="True" SaveByRuleGroup="" Deterministic="True" />
+ <EnableMultithreadedLoad>True</EnableMultithreadedLoad>
+ <EnableMultithreadedAnalysis>True</EnableMultithreadedAnalysis>
+ <SourceLookup>True</SourceLookup>
+ <AnalysisExceptionsThreshold>10</AnalysisExceptionsThreshold>
+ <RuleExceptionsThreshold>1</RuleExceptionsThreshold>
+ <Spelling Locale="en-US" />
+ <OverrideRuleVisibilities>False</OverrideRuleVisibilities>
+ <CustomDictionaries SearchFxCopDir="True" SearchUserProfile="True" SearchProjectDir="True" />
+ <SearchGlobalAssemblyCache>False</SearchGlobalAssemblyCache>
+ <DeadlockDetectionTimeout>120</DeadlockDetectionTimeout>
+ <IgnoreGeneratedCode>False</IgnoreGeneratedCode>
+ </ProjectOptions>
+ <Targets>
+ <Target Name="$(ProjectDir)/bin/Debug/AnalysisEngine.dll" Analyze="True" AnalyzeAllChildren="True" />
+ <Target Name="$(ProjectDir)/bin/Debug/bugreport.exe" Analyze="True" AnalyzeAllChildren="True" />
+ </Targets>
+ <Rules>
+ <RuleFiles>
+ <RuleFile Name="$(FxCopDir)\Rules\DesignRules.dll" Enabled="True" AllRulesEnabled="False">
+ <Rule Name="AbstractTypesShouldNotHaveConstructors" Enabled="True" />
+ <Rule Name="AvoidEmptyInterfaces" Enabled="True" />
+ <Rule Name="AvoidExcessiveParametersOnGenericTypes" Enabled="True" />
+ <Rule Name="AvoidNamespacesWithFewTypes" Enabled="True" />
+ <Rule Name="AvoidOutParameters" Enabled="True" />
+ <Rule Name="CollectionsShouldImplementGenericInterface" Enabled="True" />
+ <Rule Name="ConsiderPassingBaseTypesAsParameters" Enabled="True" />
+ <Rule Name="DeclareEventHandlersCorrectly" Enabled="True" />
+ <Rule Name="DeclareTypesInNamespaces" Enabled="True" />
+ <Rule Name="DefaultParametersShouldNotBeUsed" Enabled="True" />
+ <Rule Name="DefineAccessorsForAttributeArguments" Enabled="True" />
+ <Rule Name="DoNotCatchGeneralExceptionTypes" Enabled="True" />
+ <Rule Name="DoNotDeclareProtectedMembersInSealedTypes" Enabled="True" />
+ <Rule Name="DoNotDeclareStaticMembersOnGenericTypes" Enabled="True" />
+ <Rule Name="DoNotDeclareVirtualMembersInSealedTypes" Enabled="True" />
+ <Rule Name="DoNotExposeGenericLists" Enabled="True" />
+ <Rule Name="DoNotHideBaseClassMethods" Enabled="True" />
+ <Rule Name="DoNotNestGenericTypesInMemberSignatures" Enabled="True" />
+ <Rule Name="DoNotOverloadOperatorEqualsOnReferenceTypes" Enabled="True" />
+ <Rule Name="DoNotPassTypesByReference" Enabled="True" />
+ <Rule Name="DoNotRaiseExceptionsInUnexpectedLocations" Enabled="True" />
+ <Rule Name="EnumeratorsShouldBeStronglyTyped" Enabled="True" />
+ <Rule Name="EnumsShouldHaveZeroValue" Enabled="True" />
+ <Rule Name="EnumStorageShouldBeInt32" Enabled="True" />
+ <Rule Name="ExceptionsShouldBePublic" Enabled="True" />
+ <Rule Name="GenericMethodsShouldProvideTypeParameter" Enabled="True" />
+ <Rule Name="ICollectionImplementationsHaveStronglyTypedMembers" Enabled="True" />
+ <Rule Name="ImplementIDisposableCorrectly" Enabled="True" />
+ <Rule Name="ImplementStandardExceptionConstructors" Enabled="True" />
+ <Rule Name="IndexersShouldNotBeMultidimensional" Enabled="True" />
+ <Rule Name="InterfaceMethodsShouldBeCallableByChildTypes" Enabled="True" />
+ <Rule Name="ListsAreStronglyTyped" Enabled="True" />
+ <Rule Name="MarkAttributesWithAttributeUsage" Enabled="True" />
+ <Rule Name="MarkEnumsWithFlags" Enabled="True" />
+ <Rule Name="MembersShouldNotExposeCertainConcreteTypes" Enabled="True" />
+ <Rule Name="MovePInvokesToNativeMethodsClass" Enabled="True" />
+ <Rule Name="NestedTypesShouldNotBeVisible" Enabled="True" />
+ <Rule Name="OverloadOperatorEqualsOnOverloadingAddAndSubtract" Enabled="True" />
+ <Rule Name="OverrideMethodsOnComparableTypes" Enabled="True" />
+ <Rule Name="PropertiesShouldNotBeWriteOnly" Enabled="True" />
+ <Rule Name="ProvideObsoleteAttributeMessage" Enabled="True" />
+ <Rule Name="ReplaceRepetitiveArgumentsWithParamsArray" Enabled="True" />
+ <Rule Name="StaticHolderTypesShouldBeSealed" Enabled="True" />
+ <Rule Name="StaticHolderTypesShouldNotHaveConstructors" Enabled="True" />
+ <Rule Name="StringUriOverloadsCallSystemUriOverloads" Enabled="True" />
+ <Rule Name="TypesShouldNotExtendCertainBaseTypes" Enabled="True" />
+ <Rule Name="TypesThatOwnNativeResourcesShouldBeDisposable" Enabled="True" />
+ <Rule Name="UriParametersShouldNotBeStrings" Enabled="True" />
+ <Rule Name="UriPropertiesShouldNotBeStrings" Enabled="True" />
+ <Rule Name="UriReturnValuesShouldNotBeStrings" Enabled="True" />
+ <Rule Name="UseEventsWhereAppropriate" Enabled="True" />
+ <Rule Name="UseGenericEventHandlerInstances" Enabled="True" />
+ <Rule Name="UseGenericsWhereAppropriate" Enabled="True" />
+ <Rule Name="UseIntegralOrStringArgumentForIndexers" Enabled="True" />
+ <Rule Name="UsePropertiesWhereAppropriate" Enabled="True" />
+ </RuleFile>
+ <RuleFile Name="$(FxCopDir)\Rules\GlobalizationRules.dll" Enabled="False" AllRulesEnabled="False" />
+ <RuleFile Name="$(FxCopDir)\Rules\InteroperabilityRules.dll" Enabled="False" AllRulesEnabled="False" />
+ <RuleFile Name="$(FxCopDir)\Rules\MobilityRules.dll" Enabled="True" AllRulesEnabled="True" />
+ <RuleFile Name="$(FxCopDir)\Rules\NamingRules.dll" Enabled="True" AllRulesEnabled="False">
+ <Rule Name="DoNotNameEnumValuesReserved" Enabled="True" />
+ <Rule Name="DoNotPrefixEnumValuesWithTypeName" Enabled="True" />
+ <Rule Name="EventsShouldNotHaveBeforeOrAfterPrefix" Enabled="True" />
+ <Rule Name="FlagsEnumsShouldHavePluralNames" Enabled="True" />
+ <Rule Name="IdentifiersShouldDifferByMoreThanCase" Enabled="True" />
+ <Rule Name="IdentifiersShouldHaveCorrectSuffix" Enabled="True" />
+ <Rule Name="IdentifiersShouldNotHaveIncorrectPrefix" Enabled="True" />
+ <Rule Name="IdentifiersShouldNotHaveIncorrectSuffix" Enabled="True" />
+ <Rule Name="IdentifiersShouldNotMatchKeywords" Enabled="True" />
+ <Rule Name="OnlyFlagsEnumsShouldHavePluralNames" Enabled="True" />
+ <Rule Name="ParameterNamesShouldMatchBaseDeclaration" Enabled="True" />
+ <Rule Name="ParameterNamesShouldNotMatchMemberNames" Enabled="True" />
+ <Rule Name="PropertyNamesShouldNotMatchGetMethods" Enabled="True" />
+ <Rule Name="ResourceStringCompoundWordsShouldBeCasedCorrectly" Enabled="True" />
+ <Rule Name="ResourceStringsShouldBeSpelledCorrectly" Enabled="True" />
+ <Rule Name="TypeNamesShouldNotMatchNamespaces" Enabled="True" />
+ </RuleFile>
+ <RuleFile Name="$(FxCopDir)\Rules\PerformanceRules.dll" Enabled="True" AllRulesEnabled="False">
+ <Rule Name="AvoidExcessiveLocals" Enabled="True" />
+ <Rule Name="AvoidUncalledPrivateCode" Enabled="True" />
+ <Rule Name="AvoidUninstantiatedInternalClasses" Enabled="True" />
+ <Rule Name="AvoidUnsealedAttributes" Enabled="True" />
+ <Rule Name="AvoidUnusedPrivateFields" Enabled="True" />
+ <Rule Name="DoNotCastUnnecessarily" Enabled="True" />
+ <Rule Name="DoNotInitializeUnnecessarily" Enabled="True" />
+ <Rule Name="InitializeReferenceTypeStaticFieldsInline" Enabled="True" />
+ <Rule Name="MarkAssembliesWithNeutralResourcesLanguage" Enabled="True" />
+ <Rule Name="OverrideEqualsAndOperatorEqualsOnValueTypes" Enabled="True" />
+ <Rule Name="PreferJaggedArraysOverMultidimensional" Enabled="True" />
+ <Rule Name="PropertiesShouldNotReturnArrays" Enabled="True" />
+ <Rule Name="RemoveEmptyFinalizers" Enabled="True" />
+ <Rule Name="RemoveUnusedLocals" Enabled="True" />
+ <Rule Name="TestForEmptyStringsUsingStringLength" Enabled="True" />
+ <Rule Name="UseLiteralsWhereAppropriate" Enabled="True" />
+ </RuleFile>
+ <RuleFile Name="$(FxCopDir)\Rules\PortabilityRules.dll" Enabled="True" AllRulesEnabled="True" />
+ <RuleFile Name="$(FxCopDir)\Rules\SecurityRules.dll" Enabled="False" AllRulesEnabled="False">
+ <Rule Name="ArrayFieldsShouldNotBeReadOnly" Enabled="True" />
+ <Rule Name="DoNotDeclareReadOnlyMutableReferenceTypes" Enabled="True" />
+ <Rule Name="SealMethodsThatSatisfyPrivateInterfaces" Enabled="True" />
+ <Rule Name="SecuredTypesShouldNotExposeFields" Enabled="True" />
+ <Rule Name="StaticConstructorsShouldBePrivate" Enabled="True" />
+ </RuleFile>
+ <RuleFile Name="$(FxCopDir)\Rules\UsageRules.dll" Enabled="True" AllRulesEnabled="True" />
+ </RuleFiles>
+ <Groups />
+ <Settings />
+ </Rules>
+ <FxCopReport Version="1.36">
+ <Namespaces>
+ <Namespace Name="bugreport.DumpFileParserTests">
+ <Messages>
+ <Message TypeName="AvoidNamespacesWithFewTypes" Category="Microsoft.Design" CheckId="CA1020" Created="2008-02-27 22:34:33Z">
+ <Issue>
+ <Item>bugreport.DumpFileParserTests</Item>
+ </Issue>
+ </Message>
+ </Messages>
+ </Namespace>
+ <Namespace Name="bugreport.ElfFileParserTests">
+ <Messages>
+ <Message TypeName="AvoidNamespacesWithFewTypes" Category="Microsoft.Design" CheckId="CA1020" Created="2008-02-27 22:34:33Z">
+ <Issue>
+ <Item>bugreport.ElfFileParserTests</Item>
+ </Issue>
+ </Message>
+ </Messages>
+ </Namespace>
+ </Namespaces>
+ <Targets>
+ <Target Name="$(ProjectDir)/bin/Debug/AnalysisEngine.dll">
+ <Modules>
+ <Module Name="analysisengine.dll">
+ <Namespaces>
+ <Namespace Name="bugreport">
+ <Types>
+ <Type Name="InvalidOpcodeException">
+ <Messages>
+ <Message TypeName="ImplementStandardExceptionConstructors" Category="Microsoft.Design" CheckId="CA1032" Created="2008-02-27 22:34:33Z">
+ <Issue Name="MissingConstructor">
+ <Item>'InvalidOpcodeException'</Item>
+ <Item>protected InvalidOpcodeException(SerializationInfo, StreamingContext)</Item>
+ </Issue>
+ <Issue Name="MissingConstructor">
+ <Item>'InvalidOpcodeException'</Item>
+ <Item>public InvalidOpcodeException()</Item>
+ </Issue>
+ <Issue Name="MissingConstructor">
+ <Item>'InvalidOpcodeException'</Item>
+ <Item>public InvalidOpcodeException(String)</Item>
+ </Issue>
+ <Issue Name="MissingConstructor">
+ <Item>'InvalidOpcodeException'</Item>
+ <Item>public InvalidOpcodeException(String, Exception)</Item>
+ </Issue>
+ </Message>
+ <Message TypeName="MarkISerializableTypesWithSerializable" Category="Microsoft.Usage" CheckId="CA2237" Created="2008-02-27 22:34:33Z">
+ <Issue Certainty="95" Level="Error">
+ <Item>'InvalidOpcodeException'</Item>
+ </Issue>
+ </Message>
+ </Messages>
+ </Type>
+ <Type Name="RegisterCollection">
+ <Messages>
+ <Message TypeName="IdentifiersShouldNotHaveIncorrectSuffix" Category="Microsoft.Naming" CheckId="CA1711" Created="2008-02-27 22:34:33Z">
+ <Issue Name="TypeNoAlternate">
+ <Item>'RegisterCollection'</Item>
+ <Item>Collection</Item>
+ </Issue>
+ </Message>
+ </Messages>
+ </Type>
+ </Types>
+ </Namespace>
+ </Namespaces>
+ </Module>
+ </Modules>
+ </Target>
+ <Target Name="$(ProjectDir)/bin/Debug/bugreport.exe">
+ <Modules>
+ <Module Name="bugreport.exe">
+ <Namespaces>
+ <Namespace Name="bugreport">
+ <Types>
+ <Type Name="DebuggerView">
+ <Members>
+ <Member Name="#isEnter(System.String)">
+ <Messages>
+ <Message TypeName="TestForEmptyStringsUsingStringLength" Category="Microsoft.Performance" CheckId="CA1820" Created="2008-02-27 22:34:33Z">
+ <Issue Name="IsNullOrEmpty">
+ <Item>'string.operator ==(string, string)'</Item>
+ <Item>'DebuggerView.isEnter(string)'</Item>
+ </Issue>
+ </Message>
+ </Messages>
+ </Member>
+ </Members>
+ </Type>
+ </Types>
+ </Namespace>
+ </Namespaces>
+ </Module>
+ </Modules>
+ </Target>
+ </Targets>
+ <Rules>
+ <Rule TypeName="AvoidNamespacesWithFewTypes" Category="Microsoft.Design" CheckId="CA1020">
+ <Resolution Name="Default">Consider merging the types defined in '{0}' with another namespace.</Resolution>
+ </Rule>
+ <Rule TypeName="IdentifiersShouldNotHaveIncorrectSuffix" Category="Microsoft.Naming" CheckId="CA1711">
+ <Resolution Name="TypeNoAlternate">Rename type name {0} so that it does not end in '{1}'.</Resolution>
+ </Rule>
+ <Rule TypeName="ImplementStandardExceptionConstructors" Category="Microsoft.Design" CheckId="CA1032">
+ <Resolution Name="MissingConstructor">Add the following constructor to {0}: {1}.</Resolution>
+ </Rule>
+ <Rule TypeName="MarkISerializableTypesWithSerializable" Category="Microsoft.Usage" CheckId="CA2237">
+ <Resolution Name="Default">Add [Serializable] to {0} as this type implements ISerializable.</Resolution>
+ </Rule>
+ <Rule TypeName="TestForEmptyStringsUsingStringLength" Category="Microsoft.Performance" CheckId="CA1820">
+ <Resolution Name="IsNullOrEmpty">Replace the call to {0} in {1} with a call to 'String.IsNullOrEmpty'.</Resolution>
+ </Rule>
+ </Rules>
+ </FxCopReport>
+</FxCopProject>
Property changes on: bugreport.FxCop
___________________________________________________________________
Added: svn:executable
+ *
Added: lib/gendarme/AUTHORS
===================================================================
--- lib/gendarme/AUTHORS (rev 0)
+++ lib/gendarme/AUTHORS 2009-02-12 04:43:29 UTC (rev 169)
@@ -0,0 +1,17 @@
+Sebastien Pouliot <seb...@xi...>
+Aaron Tomb <at...@so...>
+Russell Morris <ru...@ru...>
+Christian Birkl <chr...@gm...>
+Néstor Salceda <nes...@gm...>
+Nidhi Rawal <son...@gm...>
+Lukasz Knop <luk...@gm...>
+JB Evain <jb...@no...>
+Daniel Abramov <ex...@vi...>
+Andreas Noever <andreas.noever at gmail.com>
+Adrian Tsai <adr...@ho...>
+Seo Sanghyeon <sa...@gm...>
+Scott Peterson <lun...@gm...>
+Cedric Vivier <ce...@ne...>
+Andres G. Aragoneses <aar...@no...>
+Peter Johanson <pe...@pe...>
+Jesse Jones <jes...@mi...>
Property changes on: lib/gendarme/AUTHORS
___________________________________________________________________
Added: svn:executable
+ *
Added: lib/gendarme/Gendarme.Framework.pdb
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Framework.pdb
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.BadPractice.dll
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.BadPractice.dll
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.BadPractice.pdb
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.BadPractice.pdb
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.Concurrency.pdb
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.Concurrency.pdb
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.Correctness.pdb
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.Correctness.pdb
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.Design.Generic.dll
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.Design.Generic.dll
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.Design.Linq.dll
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.Design.Linq.dll
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.Design.dll
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.Design.dll
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.Design.pdb
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.Design.pdb
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.Exceptions.pdb
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.Exceptions.pdb
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.Interoperability.dll
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.Interoperability.dll
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.Interoperability.pdb
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.Interoperability.pdb
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.Maintainability.dll
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.Maintainability.dll
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.Naming.dll
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.Naming.dll
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.Naming.pdb
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.Naming.pdb
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.Performance.pdb
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.Performance.pdb
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.Portability.pdb
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.Portability.pdb
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.Security.Cas.dll
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.Security.Cas.dll
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.Security.pdb
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.Security.pdb
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.Serialization.dll
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.Serialization.dll
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.Serialization.pdb
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.Serialization.pdb
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.Smells.dll
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.Smells.dll
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.Smells.pdb
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.Smells.pdb
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Gendarme.Rules.Ui.pdb
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Gendarme.Rules.Ui.pdb
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/ICSharpCode.SharpZipLib.dll
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/ICSharpCode.SharpZipLib.dll
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/MIT.X11
===================================================================
--- lib/gendarme/MIT.X11 (rev 0)
+++ lib/gendarme/MIT.X11 2009-02-12 04:43:29 UTC (rev 169)
@@ -0,0 +1,21 @@
+Copyright (c) 2005-2008 Novell, Inc and the individuals listed on the
+ChangeLog entries.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Property changes on: lib/gendarme/MIT.X11
___________________________________________________________________
Added: svn:executable
+ *
Added: lib/gendarme/Mono.Cecil.Mdb.dll
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Mono.Cecil.Mdb.dll
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Mono.Cecil.Pdb.dll
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Mono.Cecil.Pdb.dll
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Mono.Cecil.Pdb.pdb
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Mono.Cecil.Pdb.pdb
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/Mono.Cecil.pdb
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/Mono.Cecil.pdb
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/NEWS
===================================================================
--- lib/gendarme/NEWS (rev 0)
+++ lib/gendarme/NEWS 2009-02-12 04:43:29 UTC (rev 169)
@@ -0,0 +1,407 @@
+2008-11-24 Version 2.2
+
+ * Updated logo from Ana Carolia
+ * Fixed Severity/Confidence filter in Wizard
+ * Optimizations (reduced time and memory requirements)
+ * Better workaround for Mono bug #439943
+
+2008-11-10 Version 2.2 (preview 1)
+
+ This release includes the development results of the last four
+ months, including some major events like the Novell Hack Week 3
+ and the second half of GSoC 2008 work done by Nestor Salceda.
+
+ Major highlights includes:
+
+ * improvement to the framework by the addition of engines that
+ can build extra information to extend the model Cecil gives us
+ to work with.
+
+ * New [FxCopCompatibility] attribute to match between Gendarme
+ and FxCop rules. This will be used to support [SuppressMessage]
+ inside assemblies in a future release.
+
+ * New TearDown capability on rules and runners allow rules to
+ defer the reporting of defects until the analysis is completed.
+
+ * New "Audit" severity. This is used to denotate defects that,
+ too often, can't be fixed (i.e. will always be reported) but
+ needs to be audited (e.g. security items).
+
+ * By default the console runner now reports only when both
+ Severity > Low
+ i.e. skipping Low and Audit severity defects
+ Confidence > Low
+ i.e. skipping Low confidence defects
+
+ This is to help reduce false positives and get smaller reports
+ with the most important defects. You can override both option,
+ with lower or higher values, with new command switches. E.g.
+
+ gendarme --severity=audit,critical ...
+ gendarme --confidence=all ...
+
+ * The wizard runner is now, by default, limited to 1000 defects
+ on the visible API and will, like the console runner, report
+ only defects when both Severity > Low and Confidence > Low. A
+ new step in the wizard allow users to change those settings
+ before the analysis (defaults can be modified and saved).
+
+ * You can now save your rule selection as the new default in
+ the wizard. The same set will be enable next time you restart
+ the wizard.
+ * Known issue: does not work under Mono, bug #439943
+
+ and a lot of new rules including:
+
+ Gendarme.Rules.BadPractice
+ * AvoidAssemblyVersionMismatchRule [Sebastien Pouliot]
+ * DoNotUseGetInterfaceToCheckAssignabilityRule [Sebastien Pouliot]
+
+ Gendarme.Rules.Concurrency
+ * DoNotUseMethodImplOptionsSynchronizedRule [Sebastien Pouliot]
+ * ReviewLockUsedOnlyForOperationsOnVariablesRule [Cedric Vivier]
+ * ProtectCallToEventDelegatesRule [Sebastien Pouliot]
+
+ Gendarme.Rules.Correctness
+ * AttributeStringLiteralsShouldParseCorrectlyRule [Nestor Salceda]
+ * CheckParametersNullityInVisibleMethodsRule [Sebastien Pouliot]
+ * ProvideCorrectArgumentsToFormattingMethodsRule [Nestor Salceda]
+ * ReviewCastOnIntegerDivisionRule [Sebastien Pouliot]
+ * ReviewCastOnIntegerMultiplicationRule [Sebastien Pouliot]
+
+ Gendarme.Rules.Design
+ * AvoidSmallNamespaceRule [Sebastien Pouliot]
+ * ConsiderAddingInterfaceRule [Cedric Vivier]
+ * DeclareEventHandlersCorrectlyRule [Nestor Salceda]
+ * DoNotDeclareVirtualMethodsInSealedTypeRule [Sebastien Pouliot]
+ * InternalNamespacesShouldNotExposeTypesRule [Sebastien Pouliot]
+ * MarkAssemblyWithAssemblyVersionRule [Sebastien Pouliot]
+ * MarkAssemblyWithCLSCompliantRule [Sebastien Pouliot]
+ * MarkAssemblyWithComVisibleRule [Sebastien Pouliot]
+
+ Gendarme.Rules.Design.Generic
+ * AvoidMethodWithUnusedGenericTypeRule [Sebastien Pouliot]
+ * UseGenericEventHandlerRule [Sebastien Pouliot]
+ * PreferGenericsOverRefObjectRule [Sebastien Pouliot]
+
+ Gendarme.Rules.Design.Linq
+ * AvoidExtensionMethodOnSystemObjectRule [Sebastien Pouliot]
+
+ Gendarme.Rules.Exceptions
+ * InstantiateArgumentExceptionCorrectlyRule [Nestor Salceda]
+
+ Gendarme.Rules.Interoperability
+ * MarshalBooleansInPInvokeDeclarationsRule [Sebastien Pouliot]
+
+ Gendarme.Rules.Naming
+ * AvoidDeepNamespaceHierarchyRule [Sebastien Pouliot]
+ * AvoidRedundancyInMethodNameRule [Cedric Vivier]
+ * AvoidRedundancyInTypeNameRule [Cedric Vivier]
+
+ Gendarme.Rules.Performance
+ * AvoidUnneededFieldInitializationRule [Sebastien Pouliot]
+ * PreferLiteralOverInitOnlyFieldsRule [Sebastien Pouliot]
+
+ Gendarme.Rules.Security.Cas
+ * ReviewSuppressUnmanagedCodeSecurityUsageRule [Sebastien Pouliot]
+
+ Gendarme.Rules.Serialization
+ * MarkEnumerationsAsSerializableRule [Sebastien Pouliot]
+
+ Gendarme.Rules.Smells
+ * AvoidMessageChainsRule [Nestor Salceda]
+
+ Lots of rules have been updated and, in a few cases, renamed or
+ moved, to provide extended functionalities.
+
+ Move/merge changes:
+ * CAS-related Security rules were moved into Security.Cas
+ * DisposableFieldsShouldBeDisposedRule was moved from Design
+ into Correctness
+ * EnumNotEndsWithEnumOrFlagsSuffixRule was merged with
+ UseCorrectSuffixRule (Naming)
+ * FinalizersShouldCallBaseClassFinalizerRule was moved from
+ Design into Correctness
+ * ImplementGenericCollectionInterfacesRule was moved from
+ Design into Design.Generic
+
+ Contributors for this release are:
+ Peter Johanson, Nestor Salceda, Cedric Vivier, Jesse Jones,
+ Alan McGovern, Sebastien Pouliot.
+
+2008-07-14 Version 0.2.0.0
+
+ This release includes the development results of the last six
+ months, including some major events like the Novell Hack Week
+ (Winter 2008 edition), which changed much of the Gendarme
+ framework, the first "Gendarme Rule Day" and the first part of
+ GSoC 2008 work by Nestor Salceda.
+
+ General highlights:
+
+ * Performance enhancements, memory usage reduction (mostly
+ inside Cecil but the gains are very visible in Gendarme)
+ * MDB/PDB support: source files and line numbers are now
+ provided with defects [Sebastien Pouliot]
+ * New Windows installer: You can now easily enjoy Gendarme, and
+ it's wizard, from Windows computers [Sebastien Pouliot]
+ * .desktop file for the Wizard runner [Daniel Nauck]
+ * Console runner now uses color when displaying on the console
+ [Cedric Vivier]
+ * Albeit a bit invisible to end users, we started using the new
+ unit test helpers made during GHOP [Daniel Abramov]
+ * Bug fixes: works continue, like previous releases, to remove
+ false positives from existing rules;
+
+ and a lot of new rules including:
+
+ Gendarme.Rules.BadPractice
+ * AvoidCallingProblematicMethodsRule [Nestor Salceda]
+ * AvoidVisibleConstantFieldRule [Sebastien Pouliot]
+ * DoNotForgetNotImplementedMethodsRule [Cedric Vivier]
+ * DisableDebuggingCodeRule [Sebastien Pouliot]
+ * ObsoleteMessagesShouldNotBeEmptyRule [Sebastien Pouliot]
+ * ReplaceIncompleteOddnessCheckRule [Sebastien Pouliot]
+
+ Gendarme.Rules.Concurrency
+ * DoNotLockOnThisOrTypesRule [Sebastien Pouliot]
+ * DoNotLockOnWeakIdentityObjectsRule [Sebastien Pouliot]
+ * DoNotUseLockedRegionOutsideMethodRule [Andres G. Aragoneses]
+
+ Gendarme.Rules.Correctness
+ * DoNotRoundIntegersRule [Sebastien Pouliot]
+ * ReviewDoubleAssignmentRule [Sebastien Pouliot]
+ * ReviewSelfAssignmentRule [Sebastien Pouliot]
+ * ReviewUselessControlFlow [Sebastien Pouliot]
+ * ReviewUseOfInt64BitsToDoubleRule [Sebastien Pouliot]
+ * ReviewUseOfModuloOneOnIntegersRule [Sebastien Pouliot]
+
+ Gendarme.Rules.Design
+ * AvoidMultidimensionalIndexerRule [Sebastien Pouliot]
+ * AvoidRefAndOutParametersRule [Sebastien Pouliot]
+ * AvoidVisibleNestedTypesRule [Sebastien Pouliot]
+ * ConsiderConvertingFieldToNullableRule [Cedric Vivier]
+ * ConsiderUsingStaticTypeRule.cs [Sebastien Pouliot]
+ * ImplementGenericCollectionInterfacesRule [Daniel Abramov]
+ * ImplementIComparableCorreclyRule [Sebastien Pouliot]
+ * PreferIntegerOrStringForIndexersRule [Sebastien Pouliot]
+
+ Gendarme.Rules.Exception
+ * AvoidArgumentExceptionDefaultConstructorRule [Sebastien Pouliot]
+ * AvoidThrowingBasicExceptionsRule [Daniel Abramov]
+ * DoNotThrowReservedExceptionRule [Sebastien Pouliot]
+ * ExceptionShouldBeVisibleRule [Sebastien Pouliot]
+ * MissingExceptionConstructorsRule [Sebastien Pouliot]
+
+ Gendarme.Rules.Interoperability
+ * DoNotCastIntPtrToInt32Rule [Sebastien Pouliot]
+
+ Gendarme.Rules.Maintainability (new)
+ * AvoidComplexMethodsRule [Cedric Vivier]
+ * AvoidDeepInheritanceTreeRule [Sebastien Pouliot]
+ * AvoidLackOfCohesionOfMethodRule [Cedric Vivier]
+ * ConsiderUsingStopwatchRule [Cedric Vivier]
+ * PreferStringIsNullOrEmptyRule [Sebastien Pouliot]
+
+ Gendarme.Rules.Naming
+ * DoNotPrefixEventsWithAfterOrBeforeRule [Sebastien Pouliot]
+
+ Gendarme.Rules.Performance
+ * AvoidLargeNumberOfLocalVariablesRule [Sebastien Pouliot]
+ * AvoidLargeStructureRule [Sebastien Pouliot]
+ * AvoidRepetitiveCastsRule [Sebastien Pouliot]
+ * AvoidTypeGetTypeWhenPossibleRule [Sebastien Pouliot]
+ * AvoidUnusedPrivateFieldsRule [Sebastien Pouliot]
+ * AvoidUnneededUnboxingRule [Sebastien Pouliot]
+ * AvoidUnsealedUninheritedInternalClassesRule [Scott Peterson]
+ * ImplementEqualsTypeRule [Sebastien Pouliot]
+ * OverrideValueTypeDefaultsRule [Sebastien Pouliot]
+ * RemoveUnusedLocalVariablesRule [Sebastien Pouliot]
+ * UseIsOperatorRule [Seo Sanghyeon]
+ * UseTypeEmptyTypesRule [JB Evain]
+
+ Gendarme.Rules.Portability
+ * DoNotHardcodePathsRule [Daniel Abramov]
+
+ Gendarme.Rules.Serialization (new)
+ * CallBaseMethodsOnISerializableTypesRule [Nestor Salceda]
+ * DeserializeOptionalFieldRule [Sebastien Pouliot]
+ * ImplementISerializableCorrectlyRule [Nestor Salceda]
+ * MarkAllNonSerializableFieldsRule [Nestor Salceda]
+ * MissingSerializableAttributeOnISerializableTypeRule [Sebastien Pouliot]
+ * MissingSerializationConstructorRule [Sebastien Pouliot]
+ * UseCorrectSignatureForSerializationMethodsRule [Sebastien Pouliot]
+
+ Contributors for this release are:
+ Andres G. Aragoneses, Cedric Vivier, Daniel Abramov, JB Evain,
+ Nestor Salceda, Scott Peterson, Sebastien Pouliot, Seo Sanghyeon.
+
+2008-01-31 Version 0.0.5
+
+ This time Google Highly Open Participation (GHOP) was the main
+ source of new rules for Gendarme (Daniel Abramov, Andreas Noever,
+ Adrian Tsai) and even a Gendarme logo (Steve P).
+ Many thanks to all of them and to Google!
+
+ Other news includes:
+
+ * More rules: while GHOP added 40 rules, other contributors added
+ 7 more rules.
+ * Gendarme.Framework.Rocks: A new namespace, inside gendarme's
+ framework, introduce several extensions methods to ease rule
+ creation and avoid code duplication.
+ * Updated rules to be more friendly toward C# 3 code (e.g.
+ auto-implemented properties)
+ * Enhancements to existing rules to reduce false-positives. Even
+ with all the new rules the number of false-positives is lower
+ than before and Gendarme's self-test looks even better!
+
+ New rules by alphabetical order:
+
+ Gendarme.Rules.BadPractice
+ * CheckNewExceptionWithoutThrowingRule [Andreas Noever]
+ * CheckNewThreadWithoutStartRule [Andreas Noever]
+ * ConstructorShouldNotCallVirtualMethodsRule [Daniel Abramov]
+ * GetEntryAssemblyMayReturnNullRule [Daniel Abramov]
+
+ Gendarme.Rules.Concurrency
+ * NonConstantStaticFieldsShouldNotBeVisible [Andreas Noever]
+
+ Gendarme.Rules.Correctness
+ * DontCompareWithNaNRule [Sebastien Pouliot]
+
+ Gendarme.Rules.Design
+ * AbstractTypesShouldNotHavePublicConstructorsRule [Sebastien Pouliot]
+ * AttributeArgumentsShouldHaveAccessors [Daniel Abramov]
+ * AvoidEmptyInterfaceRule [Sebastien Pouliot]
+ * AvoidPropertiesWithoutGetAccessorRule [Sebastien Pouliot]
+ * AvoidPublicInstanceFieldsRule [Adrian Tsai]
+ * ConsiderConvertingMethodToPropertyRule [Adrian Tsai]
+ * DisposableFieldsShouldBeDisposedRule [Andreas Noever]
+ * DisposableTypesShouldHaveFinalizerRule [Andreas Noever]
+ * EnsureSymmetryForOverloadedOperatorsRule [Andreas Noever]
+ * EnumsShouldDefineAZeroValueRule [Sebastien Pouliot]
+ * FinalizersShouldBeProtectedRule [Daniel Abramov]
+ * FinalizersShouldCallBaseClassFinalizerRule [Daniel Abramov]
+ * FlagsShouldNotDefineAZeroValueRule [Sebastien Pouliot]
+ * MainShouldNotBePublicRule [Daniel Abramov]
+ * MissingAttributeUsageOnCustomAttributeRule [Daniel Abramov]
+ * OperatorEqualsShouldBeOverloadedRule [Andreas Noever]
+ * OverrideEqualsMethodRule [Andreas Noever]
+ * ProvideAlternativeNamesForOperatorOverloadsRule [Andreas Noever]
+ * TypesShouldBeInsideNamespacesRule [Sebastien Pouliot]
+ * TypesWithDisposableFieldsShouldBeDisposableRule [Andreas Noever]
+ * TypesWithNativeFieldsShouldBeDisposableRule [Andreas Noever]
+
+ Gendarme.Rules.Interoperability (new)
+ * GetLastErrorMustBeCalledRightAfterPInvokeRule [Andreas Noever]
+ * MarshalStringsInPInvokeDeclarationsRule [Daniel Abramov]
+ * PInvokeShouldNotBeVisibleRule [Andreas Noever]
+ * UseManagedAlternativesToPInvokeRule [Daniel Abramov]
+
+ Gendarme.Rules.Naming
+ * DoNotPrefixValuesWithEnumNameRule [Andreas Noever]
+ * DoNotUseReservedInEnumValueNamesRule [Andreas Noever]
+ * ParameterNamesShouldMatchOverridenMethodRule [Andreas Noever]
+ * UseCorrectCasing [Daniel Abramov]
+ * UseCorrectPrefixRule [Daniel Abramov]
+ * UseCorrectSuffixRule [Daniel Abramov]
+ * UsePreferredTermsRule [Daniel Abramov]
+
+ Gendarme.Rules.Performance
+ * AvoidReturningArraysOnPropertiesRule [Adrian Tsai]
+ * AvoidUnsealedConcreteAttributesRule [Daniel Abramov]
+
+ Gendarme.Rules.Portability
+ * ExitCodeIsLimitedOnUnixRule [Daniel Abramov]
+ * FeatureRequiresRootPrivilegeOnUnixRule [Andreas Noever]
+ * MonoCompatibilityReviewRule [Andreas Noever]
+
+ Gendarme.Rules.Security
+ * ArrayFieldsShouldNotBeReadOnlyRule [Andreas Noever]
+ * NativeFieldsShouldNotBeVisibleRule [Andreas Noever]
+ * StaticConstructorsShouldBePrivateRule [Daniel Abramov]
+
+ Gendarme.Rules.Ui
+ * UseSTAThreadAttributeOnSWFEntryPointsRule [Daniel Abramov]
+
+2007-12-20 Version 0.0.4
+
+ After a long time, many fixes, useful features (e.g. inclusion and
+ exclusion) and hours trimming down false positives, we're proud to
+ announce Gendarme 0.0.4!
+
+ Many of the new rules were contributed during the Google Summer
+ of Code 2007.
+
+ Gendarme.Rules.BadPractice
+ * CloneMethodShouldNotReturnNullRule [Nidhi Rawal]
+ * EqualShouldHandleNullArgRule [Nidhi Rawal]
+ * ImplementingEqualsButNotGetHashCodeAndViceVersaRule [Nidhi Rawal]
+ * ToStringReturnsNullRule [Nidhi Rawal]
+
+ Gendarme.Rules.Concurrency
+ * WriteStaticFieldFromInstanceMethodRule [Sebastien Pouliot]
+
+ Gendarme.Rules.Correcness
+ * AvoidConstructorsInStaticTypesRule [Lukasz Knop]
+ * CallingEqualsWithNullArgRule [Nidhi Rawal]
+ * FloatComparisonRule [Lukasz Knop]
+ * MethodCanBeMadeStaticRule [JB Evain]
+ * UseValueInPropertySetterRule [Lukasz Knop]
+
+ Gendarme.Rules.Design (new)
+ * DontDeclareProtectedFieldsInSealedClassRule [Nidhi Rawal]
+ * UsingCloneWithoutImplementingICloneableRule [Nidhi Rawal]
+
+ Gendarme.Rules.Exceptions
+ * DontSwallowErrorsCatchingNonspecificExceptionRule [Nestor Salceda]
+
+ Gendarme.Rules.Naming (new)
+ * AttributesEndsWithAttributeSuffixRule [Nestor Salceda]
+ * DetectNonAlphaNumericsInTypeNamesRule [Nidhi Rawal]
+ * EnumsNotEndsWIthEnumOrFlagsSuffixRule [Nestor Salceda]
+ * UsePluralNameInEnumFlagsRule [Nestor Salceda]
+ * UseSingularNameInEnumsUnlessAreFlagsRule [Nestor Salceda]
+
+ Gendarme.Rules.Performance
+ * AvoidToStringOnStringRule [Lukasz Knop]
+ * AvoidUncalledPrivateCodeRule [Nidhi Rawal]
+ * AvoidUninstantiatedInternalClassesRule [Nidhi Rawal]
+ * AvoidUnusedParametersRule [Nestor Salceda]
+ * DontIgnoreMethodResultRule [Lukasz Knop]
+
+ Gendarme.Rules.Smells (new)
+ * AvoidCodeDuplicatedInSameClassRule [Nestor Salceda]
+ * AvoidCodeDuplicatedInSiblingClassesRule [Nestor Salceda]
+ * AvoidLargeClassRule [Nestor Salceda]
+ * AvoidLongMethodsRule [Nestor Salceda]
+ * AvoidLongParameterListsRule [Nestor Salceda]
+ * AvoidSpeculativeGeneralityRule [Nestor Salceda]
+
+ Gendarme.Rules.Ui (new)
+ * GtkSharpExecutableTargetRule [Sebastien Pouliot]
+ * SystemWindowsFormsExecutableTargetRule [Sebastien Pouliot]
+
+ A special thanks to Nestor Salceda for his continuing dedication
+ to the project including a lot of "not so fun" (but so important)
+ tasks, like merging, rule documentation & bug hunting. You rock!
+
+2006-10-16 Version 0.0.3
+
+ * New rule for String.Empty [Sebastien Pouliot]
+ * New XML and HTML (via XSL transform) output [Christian Birkl,
+ Sebastien Pouliot]
+ * Updated to latest Cecil API [JBEvain]
+
+2006-06-19 Version 0.0.2
+
+ * Aaron Tomb added new rules for Concurrency and Correctness (based
+ on his works in Google's Summer of Code 2005) and updated the
+ framework;
+ * Russell Morris added new rules for exceptions management.
+
+2005-11-03 Version 0.0.1
+
+ * Initial version. Expect everything to change before 0.0.2 ;-)
Property changes on: lib/gendarme/NEWS
___________________________________________________________________
Added: svn:executable
+ *
Added: lib/gendarme/README
===================================================================
--- lib/gendarme/README (rev 0)
+++ lib/gendarme/README 2009-02-12 04:43:29 UTC (rev 169)
@@ -0,0 +1,27 @@
+Gendarme README
+
+User-level documentation is available from the Mono:: project wiki
+http://www.mono-project.com/Gendarme
+
+ROADMAP
+http://www.mono-project.com/Gendarme.Roadmap
+
+Mailing list
+http://groups.google.com/group/gendarme
+
+Newsgroup gateway to the mailing list
+nntp://news.gmane.org/gmane.comp.gnome.mono.gendarme
+
+Developer documentation
+http://groups.google.com/group/gendarme
+
+
+IMPORTANT NOTES
+
+* Gendarme "official" build system is based on the auto*/Makefile files
+and tested on monobuild. See mono-tools on http://mono.ximian.com/monobuild/
+(checking out gendarme without its parent dir 'mono-tools' is not supported)
+
+* MonoDevelop and Visual Studio project files are NOT always up to date
+with Makefiles. This depends on the developer making changes and his
+personal access to the developing environments.
Property changes on: lib/gendarme/README
___________________________________________________________________
Added: svn:executable
+ *
Added: lib/gendarme/gendarme-wizard.exe
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/gendarme-wizard.exe
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/gendarme.1
===================================================================
--- lib/gendarme/gendarme.1 (rev 0)
+++ lib/gendarme/gendarme.1 2009-02-12 04:43:29 UTC (rev 169)
@@ -0,0 +1,97 @@
+.\"
+.\" Gendarme manual page.
+.\"
+.\" Author:
+.\" Sebastien Pouliot <seb...@xi...>
+.\"
+.\" Copyright (C) 2005-2006,2008 Novell, Inc (http://www.novell.com)
+.\"
+
+.de Sp
+.if t .sp .5v
+.if n .sp
+..
+.TH Gendarme "Gendarme 2.2.0.0"
+.SH NAME
+Gendarme \- Rule-based code analysis for Mono::
+.SH SYNOPSIS
+.PP
+.B gendarme [--config configfile] [--set ruleset] [--log file | --xml file | --html file] [options] assemblies ...
+.SH DESCRIPTION
+\fIGendarme\fP is a extensible rule-based tool to find problems in .NET
+applications and libraries. Gendarme inspects programs and libraries that
+contain code in ECMA CIL format (Mono and .NET) and looks for common
+problems with the code, problems that compiler do not typically check or
+have not historically checked.
+.SH OPTIONS
+.TP
+.I "--config configfile"
+Specify the configuration file. Default is 'rules.xml'.
+.TP
+.I "--set ruleset"
+Specify the set of rules to verify. Default is '*'.
+.TP
+.I "--log file"
+Save the text output to the specified file.
+.TP
+.I "--xml file"
+Save the output, formatted as XML, to the specified file.
+.TP
+.I "--html file"
+Save the output, formatted as HTML, to the specified file.
+.TP
+.I "--ignore ignore-file"
+Do not report the known defects that are part of the specified file.
+.TP
+.I "--limit N"
+Stop reporting after N defects are found.
+.TP
+.I "--severity [all | audit[+] | low[+|-] | medium[+|-] | high[+|-] | critical[-]],...
+Filter the reported defects to include the specified severity levels.
+Default is 'medium+' (i.e. low and audit levels are ignored).
+.TP
+.I "--confidence [all | low[+] | normal[+|-] | high[+|-] | total[-]],...
+Filter the reported defects to include the specified confidence levels.
+Default is 'normal+' (i.e. low level is ignored).
+.TP
+.I "--quiet"
+Display minimal output (results) from the runner.
+.TP
+.I "--v|verbose"
+Enable debugging output. You can supply several -v to augment debugging verbosity.
+.TP
+.I "--version"
+Display Gendarme's version number. This number match the Mono release
+where it was released.
+.TP
+.I "assemblies ..."
+Specify the assemblies to verify. You can specify multiple filenames,
+including masks (? and *). You can also provide a file that list several
+assemblies (one by line) by prefixing the filename with @ on the command
+line.
+.SH FILES
+.TP
+.I rules.xml
+This files contains a list of all the rulesets available to Gendarme. Each
+ruleset includes a list of assemblies in which some, or all, rules can be
+verified (include) or not (exclude).
+.SH ENVIRONMENT VARIABLES
+.TP
+.I GENDARME_COLOR
+The runner will use colors when displaying defects on the console.
+By default colors are dark in order to display correctly on any
+background. You can change this default to "light" (lighter colors
+looks nice on a dark background, or "none" so no colors will be used.
+E.g.
+.nf
+ GENDARME_COLOR=none gendarme ...
+.fi
+.SH COPYRIGHT
+Copyright (C) 2005-2008 Novell, Inc (http://www.novell.com)
+.SH MAILING LISTS
+Mailing lists are listed at the
+http://groups.google.com/group/gendarme
+.SH WEB SITE
+http://www.mono-project.com/Gendarme
+.SH SEE ALSO
+.BR mono(1)
Property changes on: lib/gendarme/gendarme.1
___________________________________________________________________
Added: svn:executable
+ *
Added: lib/gendarme/gendarme.pdb
===================================================================
(Binary files differ)
Property changes on: lib/gendarme/gendarme.pdb
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: lib/gendarme/self-test.ignore
===================================================================
--- lib/gendarme/self-test.ignore (rev 0)
+++ lib/gendarme/self-test.ignore 2009-02-12 04:43:29 UTC (rev 169)
@@ -0,0 +1,11 @@
+# OK - The rule itself needs the literal new line characters to test against them
+R: Gendarme.Rules.Portability.NewLineLiteralRule
+M: Gendarme.Framework.RuleResult Gendarme.Rules.Portability.NewLineLiteralRule::CheckMethod(Mono.Cecil.MethodDefinition)
+
+# OK - For symmetry with GetPopCount this method is not turned to static
+R: Gendarme.Rules.Correctness.MethodCanBeMadeStaticRule
+M: System.Int32 Gendarme.Framework.Helpers.StackEntryAnalysis::GetPushCount(Mono.Cecil.Cil.Instruction)
+
+# OK - false positive, the real value can't be found looking in Main alone
+R: Gendarme.Rules.Portability.ExitCodeIsLimitedOnUnixRule
+A: gendarme, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null
Property changes on: lib/gendarme/self-test.ignore
___________________________________________________________________
Added: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mat...@us...> - 2009-02-12 04:41:11
|
Revision: 168
http://bugreport.svn.sourceforge.net/bugreport/?rev=168&view=rev
Author: matt_hargett
Date: 2009-02-12 04:40:24 +0000 (Thu, 12 Feb 2009)
Log Message:
-----------
Update gendarme to 2.2 (released last month), and fix a few of the warnings it gives. The Smells ruleset is particularly noisy, and I will file some bugs with them later. Other than that, and disabling the Naming rules, we now pass cleanly :)
Modified Paths:
--------------
AssemblyInfo.cs
DebuggerCommand.cs
Main.cs
OpcodeFormatter.cs
lib/gendarme/Gendarme.Framework.dll
lib/gendarme/Gendarme.Rules.Concurrency.dll
lib/gendarme/Gendarme.Rules.Correctness.dll
lib/gendarme/Gendarme.Rules.Exceptions.dll
lib/gendarme/Gendarme.Rules.Performance.dll
lib/gendarme/Gendarme.Rules.Portability.dll
lib/gendarme/Gendarme.Rules.Security.dll
lib/gendarme/Gendarme.Rules.Ui.dll
lib/gendarme/Mono.Cecil.dll
lib/gendarme/gendarme.exe
lib/gendarme/rules.xml
Modified: AssemblyInfo.cs
===================================================================
--- AssemblyInfo.cs 2009-02-12 03:51:26 UTC (rev 167)
+++ AssemblyInfo.cs 2009-02-12 04:40:24 UTC (rev 168)
@@ -4,6 +4,7 @@
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
+using System;
using System.Reflection;
using System.Runtime.InteropServices;
@@ -15,4 +16,5 @@
//
// You can specify all values by your own or you can build default build and revision
-[assembly : AssemblyVersion("0.1.*")]
\ No newline at end of file
+[assembly : AssemblyVersion("0.1.*")]
+[assembly : CLSCompliant(true)]
Modified: DebuggerCommand.cs
===================================================================
--- DebuggerCommand.cs 2009-02-12 03:51:26 UTC (rev 167)
+++ DebuggerCommand.cs 2009-02-12 04:40:24 UTC (rev 168)
@@ -34,7 +34,7 @@
public bool IsEnter
{
- get { return input == String.Empty; }
+ get { return input.Length == 0; }
}
}
}
\ No newline at end of file
Modified: Main.cs
===================================================================
--- Main.cs 2009-02-12 03:51:26 UTC (rev 167)
+++ Main.cs 2009-02-12 04:40:24 UTC (rev 168)
@@ -15,7 +15,7 @@
private const String VERSION = "0.1";
private static Analyzer analyzer;
- public static void Main(String[] arguments)
+ internal static void Main(String[] arguments)
{
Console.WriteLine("bugreport " + VERSION);
@@ -33,13 +33,13 @@
{
Console.WriteLine(e.Message);
printUsage();
- Environment.Exit(-1);
+ Environment.Exit(1);
}
if (0 == Options.Filenames.Count)
{
Console.WriteLine("No files found by name specified");
- Environment.Exit(-1);
+ Environment.Exit(1);
}
analyzeFiles(Options.Filenames, Options.IsTracing, Options.IsDebugging);
@@ -53,7 +53,7 @@
Console.WriteLine("Expectations Were Not Met:");
Console.WriteLine(
"Expected: " + analyzer.ExpectedReportItems.Count + " Actual: " + analyzer.ActualReportItems.Count);
- Environment.Exit(-1);
+ Environment.Exit(2);
}
private static void analyzeFiles(IEnumerable<string> _fileNames, Boolean _isTracing, Boolean _isDebugging)
@@ -71,7 +71,7 @@
catch (IOException e)
{
Console.WriteLine(e.Message);
- Environment.Exit(-1);
+ Environment.Exit(3);
return; // needed to hush up a false warning in mono
}
Modified: OpcodeFormatter.cs
===================================================================
--- OpcodeFormatter.cs 2009-02-12 03:51:26 UTC (rev 167)
+++ OpcodeFormatter.cs 2009-02-12 04:40:24 UTC (rev 168)
@@ -156,59 +156,68 @@
return encaseInSquareBrackets(offset);
}
- String sourceOperand;
- var sourceIsEffectiveAddress =
- opcode.GetEncoding(code).ToString().EndsWith("Ev", StringComparison.Ordinal) ||
- opcode.GetEncoding(code).ToString().EndsWith("Eb", StringComparison.Ordinal) ||
- opcode.GetEncoding(code).ToString().EndsWith("M", StringComparison.Ordinal);
+ if (SourceIsEffectiveAddress(code) && ModRM.HasSIB(code))
+ {
+ return encaseInSquareBrackets(getSIB(code));
+ }
- if (sourceIsEffectiveAddress && ModRM.HasSIB(code))
+ if (opcode.HasSourceRegister(code))
{
- var baseRegister = SIB.GetBaseRegister(code).ToString().ToLower();
- var scaled = SIB.GetScaledRegister(code).ToString().ToLower();
- var scaler = SIB.GetScaler(code);
+ return getSourceRegister(code);
+ }
- if (SIB.GetScaledRegister(code) == RegisterName.None)
+ throw new ArgumentException(
+ "don't know how to format this code's source operand: " + formatCode(code)
+ );
+ }
+
+ private static string getSourceRegister(byte[] code)
+ {
+ var sourceOperand = opcode.GetSourceRegister(code).ToString().ToLower();
+
+ if (SourceIsEffectiveAddress(code) && opcode.HasModRM(code))
+ {
+ if (ModRM.HasIndex(code))
{
- sourceOperand = baseRegister;
+ sourceOperand += "+" + ModRM.GetIndex(code);
}
- else if (scaler == 1)
+
+ var effectiveAddressIsDereferenced = ModRM.IsEffectiveAddressDereferenced(code);
+ if (effectiveAddressIsDereferenced)
{
- sourceOperand = baseRegister + "+" + scaled;
+ sourceOperand = encaseInSquareBrackets(sourceOperand);
}
- else
- {
- sourceOperand = baseRegister + "+" + scaled + "*" + scaler;
- }
-
- sourceOperand = encaseInSquareBrackets(sourceOperand);
- return sourceOperand;
}
+ return sourceOperand;
+ }
- if (opcode.HasSourceRegister(code))
+ private static string getSIB(byte[] code)
+ {
+ string sourceOperand;
+ var baseRegister = SIB.GetBaseRegister(code).ToString().ToLower();
+ var scaled = SIB.GetScaledRegister(code).ToString().ToLower();
+ var scaler = SIB.GetScaler(code);
+
+ if (SIB.GetScaledRegister(code) == RegisterName.None)
{
- sourceOperand = opcode.GetSourceRegister(code).ToString().ToLower();
-
- if (opcode.HasModRM(code) && sourceIsEffectiveAddress)
- {
- if (ModRM.HasIndex(code))
- {
- sourceOperand += "+" + ModRM.GetIndex(code);
- }
-
- var effectiveAddressIsDereferenced = ModRM.IsEffectiveAddressDereferenced(code);
- if (effectiveAddressIsDereferenced)
- {
- sourceOperand = encaseInSquareBrackets(sourceOperand);
- }
- }
-
- return sourceOperand;
+ sourceOperand = baseRegister;
}
+ else if (scaler == 1)
+ {
+ sourceOperand = baseRegister + "+" + scaled;
+ }
+ else
+ {
+ sourceOperand = baseRegister + "+" + scaled + "*" + scaler;
+ }
+ return sourceOperand;
+ }
- throw new ArgumentException(
- "don't know how to render this code's source operand: " + formatCode(code)
- );
+ private static bool SourceIsEffectiveAddress(byte[] code)
+ {
+ return opcode.GetEncoding(code).ToString().EndsWith("Ev", StringComparison.Ordinal) ||
+ opcode.GetEncoding(code).ToString().EndsWith("Eb", StringComparison.Ordinal) ||
+ opcode.GetEncoding(code).ToString().EndsWith("M", StringComparison.Ordinal);
}
private static String formatCode(IEnumerable<byte> code)
Modified: lib/gendarme/Gendarme.Framework.dll
===================================================================
(Binary files differ)
Modified: lib/gendarme/Gendarme.Rules.Concurrency.dll
===================================================================
(Binary files differ)
Modified: lib/gendarme/Gendarme.Rules.Correctness.dll
===================================================================
(Binary files differ)
Modified: lib/gendarme/Gendarme.Rules.Exceptions.dll
===================================================================
(Binary files differ)
Modified: lib/gendarme/Gendarme.Rules.Performance.dll
===================================================================
(Binary files differ)
Modified: lib/gendarme/Gendarme.Rules.Portability.dll
===================================================================
(Binary files differ)
Modified: lib/gendarme/Gendarme.Rules.Security.dll
===================================================================
(Binary files differ)
Modified: lib/gendarme/Gendarme.Rules.Ui.dll
===================================================================
(Binary files differ)
Modified: lib/gendarme/Mono.Cecil.dll
===================================================================
(Binary files differ)
Modified: lib/gendarme/gendarme.exe
===================================================================
(Binary files differ)
Modified: lib/gendarme/rules.xml
===================================================================
--- lib/gendarme/rules.xml 2009-02-12 03:51:26 UTC (rev 167)
+++ lib/gendarme/rules.xml 2009-02-12 04:40:24 UTC (rev 168)
@@ -2,33 +2,41 @@
<ruleset name="self-test">
<rules include="*" from="Gendarme.Rules.BadPractice.dll"/>
<rules include="*" from="Gendarme.Rules.Concurrency.dll" />
- <rules include="*" exclude="NullDerefRule" from="Gendarme.Rules.Correctness.dll"/>
+ <rules include="*" from="Gendarme.Rules.Correctness.dll"/>
<rules include="*" from="Gendarme.Rules.Design.dll"/>
+ <rules include="*" from="Gendarme.Rules.Design.Generic.dll"/>
+ <rules include="*" from="Gendarme.Rules.Design.Linq.dll"/>
<rules include="*" from="Gendarme.Rules.Exceptions.dll" />
<rules include="*" from="Gendarme.Rules.Interoperability.dll"/>
<rules include="*" from="Gendarme.Rules.Naming.dll"/>
<rules include="*" from="Gendarme.Rules.Performance.dll" />
<rules include="*" from="Gendarme.Rules.Portability.dll" />
<rules include="*" from="Gendarme.Rules.Security.dll" />
+ <rules include="*" from="Gendarme.Rules.Security.Cas.dll" />
<rules include="*" from="Gendarme.Rules.Serialization.dll" />
<rules include="*" from="Gendarme.Rules.Smells.dll"/>
<rules include="*" from="Gendarme.Rules.Ui.dll" />
+ <rules include="*" from="Gendarme.Rules.Maintainability.dll"/>
</ruleset>
<ruleset name="default">
<rules include="*" from="Gendarme.Rules.BadPractice.dll"/>
<rules include="*" from="Gendarme.Rules.Concurrency.dll" />
- <rules include="*" exclude="NullDerefRule" from="Gendarme.Rules.Correctness.dll"/>
+ <rules include="*" from="Gendarme.Rules.Correctness.dll"/>
<rules include="*" from="Gendarme.Rules.Design.dll"/>
+ <rules include="*" from="Gendarme.Rules.Design.Generic.dll"/>
+ <rules include="*" from="Gendarme.Rules.Design.Linq.dll"/>
<rules include="*" from="Gendarme.Rules.Exceptions.dll" />
<rules include="*" from="Gendarme.Rules.Interoperability.dll"/>
- <rules include="*" from="Gendarme.Rules.Naming.dll"/>
+<!-- <rules include="*" from="Gendarme.Rules.Naming.dll"/> -->
<rules include="*" from="Gendarme.Rules.Performance.dll" />
<rules include="*" from="Gendarme.Rules.Portability.dll" />
<rules include="*" from="Gendarme.Rules.Security.dll" />
+ <rules include="*" from="Gendarme.Rules.Security.Cas.dll" />
<rules include="*" from="Gendarme.Rules.Serialization.dll" />
+ <rules include="*" from="Gendarme.Rules.Smells.dll" />
<rules include="*" from="Gendarme.Rules.Ui.dll" />
- <!-- no rule from Smells is included in this set -->
+ <rules include="*" from="Gendarme.Rules.Maintainability.dll"/>
</ruleset>
<ruleset name="mono-bcl">
@@ -58,6 +66,9 @@
<ruleset name="security">
<rules include="*" from="Gendarme.Rules.Security.dll" />
</ruleset>
+ <ruleset name="security-cas">
+ <rules include="*" from="Gendarme.Rules.Security.Cas.dll" />
+ </ruleset>
<ruleset name="performance">
<rules include="*" from="Gendarme.Rules.Performance.dll" />
</ruleset>
@@ -82,10 +93,19 @@
<ruleset name="design">
<rules include="*" from="Gendarme.Rules.Design.dll"/>
</ruleset>
+ <ruleset name="design-generic">
+ <rules include="*" from="Gendarme.Rules.Design.Generic.dll"/>
+ </ruleset>
+ <ruleset name="design-linq">
+ <rules include="*" from="Gendarme.Rules.Design.Linq.dll"/>
+ </ruleset>
<ruleset name="interoperability">
<rules include="*" from="Gendarme.Rules.Interoperability.dll"/>
</ruleset>
<ruleset name="serialization">
<rules include="*" from="Gendarme.Rules.Serialization.dll"/>
</ruleset>
+ <ruleset name="maintainability">
+ <rules include="*" from="Gendarme.Rules.Maintainability.dll"/>
+ </ruleset>
</gendarme>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mat...@us...> - 2009-02-12 03:52:10
|
Revision: 167
http://bugreport.svn.sourceforge.net/bugreport/?rev=167&view=rev
Author: matt_hargett
Date: 2009-02-12 03:51:26 +0000 (Thu, 12 Feb 2009)
Log Message:
-----------
Massive cleanup toward C# 3.0 features with the help of ReSharper nightly builds. Added X86EmulatorTest.BugComplicatedMuthafuqqa() that should demonstrate the current issue with interfunction-immediate-parameter test. Still not sure what exactly the problem is, though. Need to step through the new unit test and look for suspicious activity.
Modified Paths:
--------------
AbstractBuffer.cs
AbstractBufferTest.cs
AbstractValue.cs
AbstractValueTest.cs
Analyzer.cs
AnalyzerTest.cs
AssemblyInfo.cs
BitMath.cs
BitMathTest.cs
Contract.cs
DebuggerView.cs
DumpFileParser.cs
DumpFileParserTest.cs
ElfFileParser.cs
ElfFileParserTest.cs
GLibcStartMainContract.cs
GLibcStartMainContractTest.cs
InvalidOpcodeException.cs
MachineState.cs
MachineStateTest.cs
Main.cs
MainTest.cs
MallocContract.cs
ModRM.cs
ModRMTest.cs
Opcode.cs
OpcodeFormatter.cs
Options.cs
OptionsTest.cs
RegisterCollection.cs
ReportItem.cs
SIB.cs
SIBTests.cs
X86Emulator.cs
X86EmulatorTest.cs
X86Opcode.cs
X86OpcodeTest.cs
Modified: AbstractBuffer.cs
===================================================================
--- AbstractBuffer.cs 2009-02-02 22:36:43 UTC (rev 166)
+++ AbstractBuffer.cs 2009-02-12 03:51:26 UTC (rev 167)
@@ -8,7 +8,7 @@
namespace bugreport
{
- public class AbstractBuffer
+ public sealed class AbstractBuffer
{
private readonly Int32 allocatedLength;
private UInt32 baseIndex;
@@ -28,7 +28,7 @@
Array.Copy(_copyMe.storage, storage, _copyMe.storage.Length);
}
- public UInt32 BaseIndex
+ private UInt32 BaseIndex
{
get { return baseIndex; }
}
@@ -73,7 +73,7 @@
public AbstractBuffer DoOperation(OperatorEffect _operatorEffect, AbstractValue _rhs)
{
- AbstractBuffer lhs = this;
+ var lhs = this;
// TODO: should have a guard for if _rhs isn't a pointer
switch (_operatorEffect)
@@ -102,10 +102,10 @@
throw new ArgumentOutOfRangeException(
String.Format(
"Attempting to set a negative baseindex, baseindex: {0:x4}, _subValue {1:x4}",
- result.baseIndex,
+ result.baseIndex,
_rhs.Value
- )
- );
+ )
+ );
}
result.baseIndex -= _rhs.Value;
@@ -147,8 +147,7 @@
for (; i < _newLength; i++)
{
- _copyTo[i] = new AbstractValue(AbstractValue.UNKNOWN);
- _copyTo[i].IsOOB = true;
+ _copyTo[i] = new AbstractValue(AbstractValue.UNKNOWN) {IsOOB = true};
}
storage = _copyTo;
Modified: AbstractBufferTest.cs
===================================================================
--- AbstractBufferTest.cs 2009-02-02 22:36:43 UTC (rev 166)
+++ AbstractBufferTest.cs 2009-02-12 03:51:26 UTC (rev 167)
@@ -15,31 +15,31 @@
[Test]
public void Copy()
{
- AbstractValue[] values = AbstractValue.GetNewBuffer(4);
+ var values = AbstractValue.GetNewBuffer(4);
var buffer = new AbstractBuffer(values);
var newBuffer = new AbstractBuffer(buffer);
Assert.AreNotSame(newBuffer, buffer);
- for (Int32 index = 0; index < newBuffer.Length; index++)
+ for (var index = 0; index < newBuffer.Length; index++)
{
Assert.AreSame(newBuffer[index], buffer[index]);
}
}
[Test]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
+ [ExpectedException(typeof (ArgumentOutOfRangeException))]
public void InvalidPointerAnd()
{
var one = new AbstractValue(0x1);
var buffer = new AbstractBuffer(new[] {one});
- AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Sub, new AbstractValue(3));
+ var modifiedBuffer = buffer.DoOperation(OperatorEffect.Sub, new AbstractValue(3));
modifiedBuffer.DoOperation(OperatorEffect.And, new AbstractValue(0xf));
}
[Test]
public void OverflowDoesntLoseIncrement()
{
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
+ var buffer = AbstractValue.GetNewBuffer(16);
var pointer = new AbstractBuffer(buffer);
var value = new AbstractValue(0x41);
value = value.AddTaint();
@@ -72,7 +72,7 @@
var two = new AbstractValue(0x2);
var three = new AbstractValue(0x3);
var four = new AbstractValue(0x4);
- AbstractValue[] values = AbstractValue.GetNewBuffer(4);
+ var values = AbstractValue.GetNewBuffer(4);
values[0] = one;
values[1] = two;
@@ -81,7 +81,7 @@
var buffer = new AbstractBuffer(values);
Assert.AreEqual(one, buffer[0]);
- AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(2));
+ var modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(2));
Assert.AreEqual(three, modifiedBuffer[0]);
}
@@ -92,7 +92,7 @@
var two = new AbstractValue(0x2);
var three = new AbstractValue(0x3);
var four = new AbstractValue(0x4);
- AbstractValue[] values = AbstractValue.GetNewBuffer(4);
+ var values = AbstractValue.GetNewBuffer(4);
values[0] = one;
values[1] = two;
@@ -101,28 +101,28 @@
var buffer = new AbstractBuffer(values);
Assert.AreEqual(one, buffer[0]);
- AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(3));
+ var modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(3));
Assert.AreEqual(four, modifiedBuffer[0]);
- AbstractBuffer andedBuffer = modifiedBuffer.DoOperation(OperatorEffect.And, new AbstractValue(0xfffffff0));
+ var andedBuffer = modifiedBuffer.DoOperation(OperatorEffect.And, new AbstractValue(0xfffffff0));
Assert.AreEqual(one, andedBuffer[0]);
}
[Test]
public void PointerAssignment()
{
- AbstractValue[] values = AbstractValue.GetNewBuffer(4);
+ var values = AbstractValue.GetNewBuffer(4);
var buffer = new AbstractBuffer(values);
- AbstractBuffer assignedBuffer = buffer.DoOperation(OperatorEffect.Assignment, null);
+ var assignedBuffer = buffer.DoOperation(OperatorEffect.Assignment, null);
Assert.AreNotSame(buffer, assignedBuffer);
}
[Test]
public void PointerOverflowByOne()
{
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
+ var buffer = AbstractValue.GetNewBuffer(16);
var pointer = new AbstractBuffer(buffer);
- AbstractValue value = pointer[16];
+ var value = pointer[16];
Assert.IsTrue(value.IsOOB);
Assert.IsFalse(value.IsInitialized);
Assert.AreEqual(AbstractValue.UNKNOWN, value.Value);
@@ -133,7 +133,7 @@
{
var test1 = new AbstractValue(0x41);
var test2 = new AbstractValue(0x42);
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(2);
+ var buffer = AbstractValue.GetNewBuffer(2);
buffer[0] = test1;
buffer[1] = test2;
@@ -156,7 +156,7 @@
[Test]
public void PointerOverflowTwiceStillRetainsOriginalValues()
{
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
+ var buffer = AbstractValue.GetNewBuffer(16);
var pointer = new AbstractBuffer(buffer);
// Access beyond buffer bounds forcing buffer to expand
@@ -183,7 +183,7 @@
var two = new AbstractValue(0x2);
var three = new AbstractValue(0x3);
var four = new AbstractValue(0x4);
- AbstractValue[] values = AbstractValue.GetNewBuffer(4);
+ var values = AbstractValue.GetNewBuffer(4);
values[0] = one;
values[1] = two;
@@ -192,22 +192,22 @@
var buffer = new AbstractBuffer(values);
Assert.AreEqual(one, buffer[0]);
- AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(2));
+ var modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(2));
Assert.AreEqual(three, modifiedBuffer[0]);
- AbstractBuffer subbedBuffer = modifiedBuffer.DoOperation(OperatorEffect.Sub, new AbstractValue(2));
+ var subbedBuffer = modifiedBuffer.DoOperation(OperatorEffect.Sub, new AbstractValue(2));
Assert.AreEqual(one, subbedBuffer[0]);
}
[Test]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
+ [ExpectedException(typeof (ArgumentOutOfRangeException))]
public void PointerSubUnderflow()
{
new AbstractBuffer(new AbstractValue[] {}).DoOperation(OperatorEffect.Sub, new AbstractValue(1));
}
[Test]
- [ExpectedException(typeof(ArgumentException))]
+ [ExpectedException(typeof (ArgumentException))]
public void PointerUnknownOperation()
{
new AbstractBuffer(new AbstractValue[] {}).DoOperation(OperatorEffect.Unknown, null);
Modified: AbstractValue.cs
===================================================================
--- AbstractValue.cs 2009-02-02 22:36:43 UTC (rev 166)
+++ AbstractValue.cs 2009-02-12 03:51:26 UTC (rev 167)
@@ -9,7 +9,7 @@
namespace bugreport
{
- public class AbstractValue
+ public sealed class AbstractValue
{
public const UInt32 MAX_BUFFER_SIZE = 25600000;
public const UInt32 UNKNOWN = 0xb4dc0d3d;
@@ -94,7 +94,7 @@
{
get { return pointsTo != null; }
}
-
+
public static AbstractValue[] GetNewBuffer(UInt32 size)
{
if (size > MAX_BUFFER_SIZE)
@@ -129,8 +129,8 @@
public override Int32 GetHashCode()
{
- Int32 hashCode = Value.GetHashCode() ^ IsOOB.GetHashCode() ^
- IsTainted.GetHashCode();
+ var hashCode = Value.GetHashCode() ^ IsOOB.GetHashCode() ^
+ IsTainted.GetHashCode();
if (PointsTo != null)
{
@@ -142,7 +142,7 @@
public AbstractValue TruncateValueToByte()
{
- UInt32 byteValue = Value & 0xff;
+ var byteValue = Value & 0xff;
var truncatedValue = new AbstractValue(byteValue);
truncatedValue.IsTainted = IsTainted;
@@ -156,8 +156,7 @@
throw new InvalidOperationException("Cannot AddTaint to a pointer");
}
- var taintedValue = new AbstractValue(this);
- taintedValue.IsTainted = true;
+ var taintedValue = new AbstractValue(this) {IsTainted = true};
return taintedValue;
}
@@ -173,18 +172,18 @@
public override String ToString()
{
- String result = String.Empty;
+ var result = String.Empty;
if (tainted)
{
result += "t";
}
- UInt32 valueToPrint = Value;
+ var valueToPrint = Value;
if (pointsTo != null)
{
- AbstractValue pointer = pointsTo[0];
+ var pointer = pointsTo[0];
var newResult = new StringBuilder(result);
@@ -204,7 +203,7 @@
pointer = null;
}
}
-
+
result = newResult.ToString();
}
Modified: AbstractValueTest.cs
===================================================================
--- AbstractValueTest.cs 2009-02-02 22:36:43 UTC (rev 166)
+++ AbstractValueTest.cs 2009-02-12 03:51:26 UTC (rev 167)
@@ -20,7 +20,7 @@
{
var clean = new AbstractValue(0x31337);
Assert.IsFalse(clean.IsTainted);
- AbstractValue tainted = clean.AddTaint();
+ var tainted = clean.AddTaint();
Assert.IsTrue(tainted.IsTainted);
Assert.AreNotSame(clean, tainted);
}
@@ -30,20 +30,20 @@
{
var clean = new AbstractValue(0x31337);
Assert.IsFalse(clean.IsTainted);
- AbstractValue notTainted = clean.AddTaintIf(0 == 1);
+ var notTainted = clean.AddTaintIf(0 == 1);
Assert.IsFalse(notTainted.IsTainted);
Assert.AreSame(clean, notTainted);
- AbstractValue tainted = clean.AddTaintIf(1 == 1);
+ var tainted = clean.AddTaintIf(1 == 1);
Assert.IsTrue(tainted.IsTainted);
Assert.AreNotSame(clean, tainted);
}
[Test]
- [ExpectedException(typeof(InvalidOperationException))]
+ [ExpectedException(typeof (InvalidOperationException))]
public void AddTaintOnPointer()
{
- var buffer = new AbstractBuffer(AbstractValue.GetNewBuffer(1));
+ buffer = new AbstractBuffer(AbstractValue.GetNewBuffer(1));
var clean = new AbstractValue(buffer);
clean.AddTaint();
}
@@ -51,8 +51,8 @@
[Test]
public void AssignmentAtByteZero()
{
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
- pointer = new AbstractValue(buffer);
+ var values = AbstractValue.GetNewBuffer(16);
+ pointer = new AbstractValue(values);
pointer.PointsTo[0] = new AbstractValue(0x31337);
Assert.AreEqual(0x31337, pointer.PointsTo[0].Value);
Assert.AreEqual("*0x00031337", pointer.ToString());
@@ -61,26 +61,14 @@
[Test]
public void AssignmentAtEnd()
{
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
- pointer = new AbstractValue(buffer);
+ var values = AbstractValue.GetNewBuffer(16);
+ pointer = new AbstractValue(values);
pointer.PointsTo[15] = new AbstractValue(0x31337);
Assert.AreEqual(0x31337, pointer.PointsTo[15].Value);
}
[Test]
- public void CheckOOBAfterCopy()
- {
- var src = new AbstractValue(0x31337);
- src.IsOOB = false;
- var dest = new AbstractValue(0x1);
- dest.IsOOB = true;
- dest = new AbstractValue(src);
-
- Assert.IsFalse(dest.IsOOB);
- }
-
- [Test]
- [ExpectedException(typeof(ArgumentException))]
+ [ExpectedException(typeof (ArgumentException))]
public void EmptyBuffer()
{
pointer = new AbstractValue(new AbstractBuffer(new AbstractValue[] {}));
@@ -103,7 +91,7 @@
[Test]
public void NoPointer()
{
- AbstractValue value = new AbstractValue(2).AddTaint();
+ var value = new AbstractValue(2).AddTaint();
Assert.IsNull(value.PointsTo);
StringAssert.Contains("0x00000002", value.ToString());
@@ -120,13 +108,22 @@
}
[Test]
- [ExpectedException(typeof(ArgumentNullException))]
+ [ExpectedException(typeof (ArgumentNullException))]
public void NullCopyCtor()
{
pointer = new AbstractValue((AbstractValue) null);
}
[Test]
+ public void OOBSurvivesCopy()
+ {
+ var src = new AbstractValue(0x31337) {IsOOB = true};
+ var dest = new AbstractValue(src);
+
+ Assert.IsTrue(dest.IsOOB);
+ }
+
+ [Test]
public void Pointer()
{
buffer = new AbstractBuffer(new[] {new AbstractValue(2)});
@@ -169,16 +166,14 @@
[Test]
public void PreserveIsOOBAfterCopy()
{
- var src = new AbstractValue(0x31337);
- var dest = new AbstractValue(0x1);
- src.IsOOB = true;
- dest = new AbstractValue(src);
+ var src = new AbstractValue(0x31337) {IsOOB = true};
+ var dest = new AbstractValue(src);
Assert.IsTrue(dest.IsOOB);
}
[Test]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
+ [ExpectedException(typeof (ArgumentOutOfRangeException))]
public void RequestedBufferTooLarge()
{
AbstractValue.GetNewBuffer(AbstractValue.MAX_BUFFER_SIZE + 1);
@@ -188,12 +183,12 @@
public void TruncateValue()
{
var dwordValue = new AbstractValue(0xdeadbeef);
- AbstractValue byteValue = dwordValue.TruncateValueToByte();
+ var byteValue = dwordValue.TruncateValueToByte();
Assert.AreEqual(0xef, byteValue.Value);
}
[Test]
- [ExpectedException(typeof(ArgumentException))]
+ [ExpectedException(typeof (ArgumentException))]
public void ZeroSizeBuffer()
{
pointer = new AbstractValue(new AbstractValue[] {});
Modified: Analyzer.cs
===================================================================
--- Analyzer.cs 2009-02-02 22:36:43 UTC (rev 166)
+++ Analyzer.cs 2009-02-12 03:51:26 UTC (rev 167)
@@ -9,12 +9,12 @@
namespace bugreport
{
- public class EmulationEventArgs : EventArgs
+ public sealed class EmulationEventArgs : EventArgs
{
private readonly ReadOnlyCollection<Byte> code;
private readonly MachineState state;
- public EmulationEventArgs(MachineState state, ReadOnlyCollection<Byte> code)
+ internal EmulationEventArgs(MachineState state, ReadOnlyCollection<Byte> code)
{
this.state = state;
this.code = code;
@@ -31,7 +31,7 @@
}
}
- public class ReportEventArgs : EventArgs
+ public sealed class ReportEventArgs : EventArgs
{
private readonly ReportItem reportItem;
@@ -46,7 +46,7 @@
}
}
- public class ReportCollection : Collection<ReportItem>
+ public sealed class ReportCollection : Collection<ReportItem>
{
public EventHandler<ReportEventArgs> OnReport;
@@ -63,10 +63,10 @@
public class Analyzer
{
- public EventHandler<EmulationEventArgs> OnEmulationComplete;
private readonly Opcode opcode = new X86Opcode();
private readonly IParsable parser;
- private ReportCollection reportItems;
+ private readonly ReportCollection reportItems;
+ public EventHandler<EmulationEventArgs> OnEmulationComplete;
public Analyzer(IParsable parser)
{
@@ -79,7 +79,7 @@
reportItems = new ReportCollection();
}
-
+
public ReadOnlyCollection<ReportItem> ActualReportItems
{
get { return new ReadOnlyCollection<ReportItem>(reportItems); }
@@ -105,13 +105,13 @@
{
var machineState = new MachineState(getRegistersForLinuxStart());
machineState.InstructionPointer = parser.EntryPointAddress;
- Byte[] instructions = parser.GetBytes();
- UInt32 index = machineState.InstructionPointer - parser.BaseAddress;
+ var instructions = parser.GetBytes();
+ var index = machineState.InstructionPointer - parser.BaseAddress;
while (index < instructions.Length)
{
- MachineState savedState = machineState;
- Byte[] instruction = extractInstruction(instructions, index);
+ var savedState = machineState;
+ var instruction = extractInstruction(instructions, index);
machineState = runCode(machineState, instruction);
if (null != OnEmulationComplete)
@@ -138,16 +138,16 @@
{
var linuxMainDefaultValues = new RegisterCollection();
- AbstractValue arg0 = new AbstractValue(1).AddTaint();
+ var arg0 = new AbstractValue(1).AddTaint();
var argvBuffer = new[] {arg0};
var argvPointer = new AbstractValue(argvBuffer);
var argvPointerBuffer = new[] {argvPointer};
var argvPointerPointer = new AbstractValue(argvPointerBuffer);
- AbstractValue[] stackBuffer = AbstractValue.GetNewBuffer(0x200);
+ var stackBuffer = AbstractValue.GetNewBuffer(0x200);
var buffer = new AbstractBuffer(stackBuffer);
- AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(0x100));
+ var modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(0x100));
// linux ABI dictates
modifiedBuffer[5] = argvPointerPointer;
@@ -163,9 +163,9 @@
private Byte[] extractInstruction(Byte[] instructions, UInt32 index)
{
- Byte instructionLength = opcode.GetInstructionLength(instructions, index);
+ var instructionLength = opcode.GetInstructionLength(instructions, index);
var instruction = new Byte[instructionLength];
- for (UInt32 count = index; count < index + instructionLength; count++)
+ for (var count = index; count < index + instructionLength; count++)
{
instruction[count - index] = instructions[count];
}
Modified: AnalyzerTest.cs
===================================================================
--- AnalyzerTest.cs 2009-02-02 22:36:43 UTC (rev 166)
+++ AnalyzerTest.cs 2009-02-12 03:51:26 UTC (rev 167)
@@ -27,6 +27,46 @@
}
}
+ private IParsable createMockParser(UInt32 expectedReportItemCount)
+ {
+ var control = new DynamicMock(typeof (IParsable));
+ control.ExpectAndReturn("GetBytes", code, null);
+
+ var reportItemList = new List<ReportItem>();
+
+ for (UInt32 i = 0; i < expectedReportItemCount; i++)
+ {
+ reportItemList.Add(new ReportItem(i, false));
+ }
+
+ control.ExpectAndReturn("get_ExpectedReportItems", reportItemList.AsReadOnly(), null);
+ control.ExpectAndReturn("get_ExpectedReportItems", reportItemList.AsReadOnly(), null);
+ return control.MockInstance as IParsable;
+ }
+
+ private class FakeAnalyzer : Analyzer
+ {
+ private readonly UInt32 actualReportItemCount;
+
+ public FakeAnalyzer(IParsable parser, UInt32 actualReportItemCount)
+ : base(parser)
+ {
+ this.actualReportItemCount = actualReportItemCount;
+ }
+
+ protected override MachineState runCode(MachineState _machineState, Byte[] _instructionBytes)
+ {
+ for (UInt32 i = 0; i < actualReportItemCount; i++)
+ {
+ ReportItems.Add(new ReportItem(i, false));
+ }
+
+ _machineState.InstructionPointer += (UInt32) _instructionBytes.Length;
+
+ return _machineState;
+ }
+ }
+
[Test]
public void NoReportItems()
{
@@ -37,7 +77,7 @@
}
[Test]
- [ExpectedException(typeof(ArgumentNullException))]
+ [ExpectedException(typeof (ArgumentNullException))]
public void NullStream()
{
analyzer = new Analyzer(null);
@@ -79,45 +119,5 @@
Assert.AreEqual(0, reportItems[0].InstructionPointer);
Assert.AreEqual(1, reportItems[1].InstructionPointer);
}
-
- private IParsable createMockParser(UInt32 expectedReportItemCount)
- {
- var control = new DynamicMock(typeof(IParsable));
- control.ExpectAndReturn("GetBytes", code, null);
-
- var reportItemList = new List<ReportItem>();
-
- for (UInt32 i = 0; i < expectedReportItemCount; i++)
- {
- reportItemList.Add(new ReportItem(i, false));
- }
-
- control.ExpectAndReturn("get_ExpectedReportItems", reportItemList.AsReadOnly(), null);
- control.ExpectAndReturn("get_ExpectedReportItems", reportItemList.AsReadOnly(), null);
- return control.MockInstance as IParsable;
- }
-
- private class FakeAnalyzer : Analyzer
- {
- private readonly UInt32 actualReportItemCount;
-
- public FakeAnalyzer(IParsable parser, UInt32 actualReportItemCount)
- : base(parser)
- {
- this.actualReportItemCount = actualReportItemCount;
- }
-
- protected override MachineState runCode(MachineState _machineState, Byte[] _instructionBytes)
- {
- for (UInt32 i = 0; i < actualReportItemCount; i++)
- {
- ReportItems.Add(new ReportItem(i, false));
- }
-
- _machineState.InstructionPointer += (UInt32) _instructionBytes.Length;
-
- return _machineState;
- }
- }
- }
+ }
}
\ No newline at end of file
Modified: AssemblyInfo.cs
===================================================================
--- AssemblyInfo.cs 2009-02-02 22:36:43 UTC (rev 166)
+++ AssemblyInfo.cs 2009-02-12 03:51:26 UTC (rev 167)
@@ -7,11 +7,12 @@
using System.Reflection;
using System.Runtime.InteropServices;
-[assembly: ComVisible(false)]
+[assembly : ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
-[assembly: AssemblyVersion("0.1.*")]
\ No newline at end of file
+
+[assembly : AssemblyVersion("0.1.*")]
\ No newline at end of file
Modified: BitMath.cs
===================================================================
--- BitMath.cs 2009-02-02 22:36:43 UTC (rev 166)
+++ BitMath.cs 2009-02-12 03:51:26 UTC (rev 167)
@@ -22,7 +22,7 @@
for (Byte i = 0; i < 4; ++i)
{
- result |= (UInt32)data[i + index] << (8 * i);
+ result |= (UInt32) data[i + index] << (8 * i);
}
return result;
Modified: BitMathTest.cs
===================================================================
--- BitMathTest.cs 2009-02-02 22:36:43 UTC (rev 166)
+++ BitMathTest.cs 2009-02-12 03:51:26 UTC (rev 167)
@@ -15,26 +15,26 @@
[Test]
public void AllZeroes()
{
- UInt32 result = BitMath.BytesToDword(new Byte[] {0, 0, 0, 0}, 0);
+ var result = BitMath.BytesToDword(new Byte[] {0, 0, 0, 0}, 0);
Assert.AreEqual(0, result);
}
[Test]
- [ExpectedException(typeof(ArgumentException))]
+ [ExpectedException(typeof (ArgumentException))]
public void EmptyBytes()
{
BitMath.BytesToDword(new Byte[] {}, 0);
}
[Test]
- [ExpectedException(typeof(ArgumentException))]
+ [ExpectedException(typeof (ArgumentException))]
public void NotEnoughBytesToDwordAtNonZeroIndex()
{
BitMath.BytesToDword(new Byte[] {0, 1, 2, 3}, 1);
}
[Test]
- [ExpectedException(typeof(ArgumentException))]
+ [ExpectedException(typeof (ArgumentException))]
public void NotEnoughBytesToDwordAtZeroIndex()
{
BitMath.BytesToDword(new Byte[] {0}, 0);
@@ -43,7 +43,7 @@
[Test]
public void OneTwoThreeFour()
{
- UInt32 result = BitMath.BytesToDword(new Byte[] {1, 2, 3, 4}, 0);
+ var result = BitMath.BytesToDword(new Byte[] {1, 2, 3, 4}, 0);
Assert.AreEqual(0x04030201, result);
}
}
Modified: Contract.cs
===================================================================
--- Contract.cs 2009-02-02 22:36:43 UTC (rev 166)
+++ Contract.cs 2009-02-12 03:51:26 UTC (rev 167)
@@ -10,15 +10,15 @@
{
public abstract class Contract
{
- private Opcode opcode = new X86Opcode();
-
- protected Opcode Opcode
- {
- get { return opcode; }
+ private readonly Opcode opcode = new X86Opcode();
+
+ protected Opcode Opcode
+ {
+ get { return opcode; }
}
public abstract Boolean IsSatisfiedBy(MachineState state, Byte[] code);
-
+
public abstract MachineState Execute(MachineState state);
}
}
\ No newline at end of file
Modified: DebuggerView.cs
===================================================================
--- DebuggerView.cs 2009-02-02 22:36:43 UTC (rev 166)
+++ DebuggerView.cs 2009-02-12 03:51:26 UTC (rev 167)
@@ -8,7 +8,7 @@
namespace bugreport
{
- internal class DebuggerView
+ internal sealed class DebuggerView
{
private readonly Boolean interactive;
private MachineState state;
@@ -20,11 +20,11 @@
public void printInfo(object sender, EmulationEventArgs e)
{
- String address = getEffectiveAddressFor(e);
+ var address = getEffectiveAddressFor(e);
Console.Write(address + ":");
Console.Write("\t");
- Byte[] code = getCodeFor(e);
+ var code = getCodeFor(e);
printOpcodeInfo(code);
Console.WriteLine(state.Registers);
@@ -33,56 +33,56 @@
handleInputIfNecessary();
}
- protected void handleInputIfNecessary()
+ private void handleInputIfNecessary()
{
+ if (!interactive) return;
+
// TODO: cover this with a system-level test
- Boolean enterPressed = false;
- if (interactive)
+ var enterPressed = false;
+
+ while (!enterPressed)
{
- while (!enterPressed)
+ var input = getInput();
+ var command = new DebuggerCommand(input);
+ if (command.IsEnter)
{
- string input = getInput();
- var command = new DebuggerCommand(input);
- if (command.IsEnter)
- {
- enterPressed = true;
- continue;
- }
-
- if (command.IsStackPrint)
- {
- printStackFor(state);
- continue;
- }
-
- if (command.IsDisassemble)
- {
- string hex = input.Substring("disasm".Length + 1);
- byte[] code = DumpFileParser.getByteArrayFromHexString(hex);
- printOpcodeInfo(code);
- continue;
- }
-
- if (command.IsQuit)
- {
- Environment.Exit(0);
- }
+ enterPressed = true;
+ continue;
+ }
- Console.WriteLine("invalid command");
+ if (command.IsStackPrint)
+ {
+ printStackFor(state);
+ continue;
}
+
+ if (command.IsDisassemble)
+ {
+ var hex = input.Substring("disasm".Length + 1);
+ var code = DumpFileParser.getByteArrayFromHexString(hex);
+ printOpcodeInfo(code);
+ continue;
+ }
+
+ if (command.IsQuit)
+ {
+ Environment.Exit(0);
+ }
+
+ Console.WriteLine("invalid command");
}
}
private void printOpcodeInfo(byte[] code)
{
- foreach (Byte codeByte in code)
+ foreach (var codeByte in code)
{
Console.Write(String.Format("{0:x2}", codeByte) + " ");
}
// magic numbers that happen to look good :)
- Int32 numberOfTabs = 3 - (code.Length / 3);
- for (Int32 i = 0; i < numberOfTabs; i++)
+ var numberOfTabs = 3 - (code.Length / 3);
+ for (var i = 0; i < numberOfTabs; i++)
{
Console.Write("\t");
}
@@ -90,19 +90,19 @@
Console.Write(OpcodeFormatter.GetInstructionName(code));
Console.Write("\t");
- String operands = OpcodeFormatter.GetOperands(code, state.InstructionPointer);
+ var operands = OpcodeFormatter.GetOperands(code, state.InstructionPointer);
Console.Write(operands);
if (operands.Length < 8)
{
Console.Write("\t");
}
- String encoding = OpcodeFormatter.GetEncoding(code);
+ var encoding = OpcodeFormatter.GetEncoding(code);
Console.Write("\t");
Console.WriteLine(encoding);
}
- private Byte[] getCodeFor(EmulationEventArgs e)
+ private static Byte[] getCodeFor(EmulationEventArgs e)
{
var code = new Byte[e.Code.Count];
e.Code.CopyTo(code, 0);
@@ -112,7 +112,7 @@
private string getEffectiveAddressFor(EmulationEventArgs e)
{
state = e.MachineState;
- String address = String.Format("{0:x8}", state.InstructionPointer);
+ var address = String.Format("{0:x8}", state.InstructionPointer);
return address;
}
@@ -122,9 +122,9 @@
return Console.ReadLine();
}
- private void printStackFor(MachineState state)
+ private static void printStackFor(MachineState state)
{
- AbstractValue esp = state.Registers[RegisterName.ESP];
+ var esp = state.Registers[RegisterName.ESP];
Console.WriteLine("Stack dump");
Console.WriteLine("esp-8\t\t esp-4\t\t esp");
Modified: DumpFileParser.cs
===================================================================
--- DumpFileParser.cs 2009-02-02 22:36:43 UTC (rev 166)
+++ DumpFileParser.cs 2009-02-12 03:51:26 UTC (rev 167)
@@ -17,7 +17,7 @@
ReadOnlyCollection<ReportItem> ExpectedReportItems { get; }
UInt32 BaseAddress { get; }
-
+
UInt32 EntryPointAddress { get; }
Byte[] GetBytes();
@@ -44,6 +44,20 @@
opcodeList = parse();
}
+ #region IDisposable Members
+
+ public void Dispose()
+ {
+ if (null != reader)
+ {
+ reader.Dispose();
+ }
+ }
+
+ #endregion
+
+ #region IParsable Members
+
public ReadOnlyCollection<ReportItem> ExpectedReportItems
{
get { return expectedReportItems.AsReadOnly(); }
@@ -59,28 +73,6 @@
get { return entryPointAddress; }
}
- public static Byte[] getByteArrayFromHexString(String hex)
- {
- String[] hexStrings = hex.Split(new[] {' '});
-
- var hexBytes = new Byte[hexStrings.Length];
-
- for (Int32 i = 0; i < hexStrings.Length; ++i)
- {
- hexBytes[i] = Byte.Parse(hexStrings[i], NumberStyles.HexNumber);
- }
-
- return hexBytes;
- }
-
- public void Dispose()
- {
- if (null != reader)
- {
- reader.Dispose();
- }
- }
-
public Byte[] GetBytes()
{
if (opcodeList.Count == 0)
@@ -88,49 +80,66 @@
return null;
}
- Int32 total = 0;
+ var total = 0;
foreach (var bytes in opcodeList)
{
total += bytes.Length;
}
- int allByteCount = 0;
+ var allByteCount = 0;
var allBytes = new Byte[total];
foreach (var bytes in opcodeList)
{
- for (int i = 0; i < bytes.Length; i++)
+ for (var i = 0; i < bytes.Length; i++)
{
allBytes[i + allByteCount] = bytes[i];
}
-
+
allByteCount += bytes.Length;
}
return allBytes;
}
+ #endregion
+
+ public static Byte[] getByteArrayFromHexString(String hex)
+ {
+ var hexStrings = hex.Split(new[] {' '});
+
+ var hexBytes = new Byte[hexStrings.Length];
+
+ for (var i = 0; i < hexStrings.Length; ++i)
+ {
+ hexBytes[i] = Byte.Parse(hexStrings[i], NumberStyles.HexNumber);
+ }
+
+ return hexBytes;
+ }
+
private static UInt32 getAddressForLine(String line)
{
- String address = line.Substring(0, 8);
+ var address = line.Substring(0, 8);
return UInt32.Parse(address, NumberStyles.HexNumber);
}
private static String getHexWithSpaces(String line)
{
- Int32 colonIndex = line.IndexOf(':');
+ var colonIndex = line.IndexOf(':');
if (colonIndex == -1)
{
return null;
}
- else if (colonIndex != 8)
+
+ if (colonIndex != 8)
{
return null;
}
- String afterColonToEnd = line.Substring(colonIndex + 1).Trim();
- Int32 doubleSpaceIndex = afterColonToEnd.IndexOf(" ", StringComparison.Ordinal);
- Int32 spaceTabIndex = afterColonToEnd.IndexOf(" \t", StringComparison.Ordinal);
+ var afterColonToEnd = line.Substring(colonIndex + 1).Trim();
+ var doubleSpaceIndex = afterColonToEnd.IndexOf(" ", StringComparison.Ordinal);
+ var spaceTabIndex = afterColonToEnd.IndexOf(" \t", StringComparison.Ordinal);
Int32 endOfHexIndex;
if (doubleSpaceIndex >= 0 && spaceTabIndex >= 0)
@@ -147,7 +156,7 @@
return null;
}
- String hexString = afterColonToEnd.Substring(0, endOfHexIndex).Trim();
+ var hexString = afterColonToEnd.Substring(0, endOfHexIndex).Trim();
return hexString;
}
@@ -159,14 +168,14 @@
return null;
}
- String hex = getHexWithSpaces(line);
+ var hex = getHexWithSpaces(line);
if (null == hex)
{
return null;
}
- Byte[] hexBytes = getByteArrayFromHexString(hex);
+ var hexBytes = getByteArrayFromHexString(hex);
return hexBytes;
}
@@ -178,28 +187,27 @@
private static ReportItem getAnnotation(String line)
{
- Int32 locationIndex = line.IndexOf("=", StringComparison.Ordinal) + 1;
- UInt32 location = UInt32.Parse(line.Substring(locationIndex + "/>".Length, 8), NumberStyles.HexNumber);
- Int32 exploitableIndex = line.IndexOf("=", locationIndex + 1, StringComparison.Ordinal) + 1;
- Boolean exploitable =
+ var locationIndex = line.IndexOf("=", StringComparison.Ordinal) + 1;
+ var location = UInt32.Parse(line.Substring(locationIndex + "/>".Length, 8), NumberStyles.HexNumber);
+ var exploitableIndex = line.IndexOf("=", locationIndex + 1, StringComparison.Ordinal) + 1;
+ var exploitable =
Boolean.Parse(line.Substring(exploitableIndex, (line.Length - exploitableIndex) - "/>".Length));
return new ReportItem(location, exploitable);
}
private void updateMainInfo(String line)
{
- if (line.Length > 0 && line[0] >= '0' && line[0] <= '7')
+ if (String.IsNullOrEmpty(line) || line[0] < '0' || line[0] > '7') return;
+
+ if (line.Contains("<_start>:"))
{
- if (line.Contains("<_start>:"))
- {
- baseAddress = getAddressForLine(line);
- inTextSection = true;
- }
+ baseAddress = getAddressForLine(line);
+ inTextSection = true;
+ }
- if (line.Contains("<" + functionNameToParse + ">:"))
- {
- entryPointAddress = getAddressForLine(line);
- }
+ if (line.Contains("<" + functionNameToParse + ">:"))
+ {
+ entryPointAddress = getAddressForLine(line);
}
}
@@ -209,10 +217,10 @@
while (!reader.EndOfStream)
{
- String currentLine = reader.ReadLine();
+ var currentLine = reader.ReadLine();
if (hasAnnotation(currentLine))
{
- ReportItem item = getAnnotation(currentLine);
+ var item = getAnnotation(currentLine);
expectedReportItems.Add(item);
}
@@ -220,14 +228,14 @@
if (inTextSection)
{
- Byte[] opcode = getHexFromString(currentLine);
+ var opcode = getHexFromString(currentLine);
if (opcode != null)
{
opcodes.Add(getHexFromString(currentLine));
}
}
}
-
+
return opcodes;
}
}
Modified: DumpFileParserTest.cs
===================================================================
--- DumpFileParserTest.cs 2009-02-02 22:36:43 UTC (rev 166)
+++ DumpFileParserTest.cs 2009-02-12 03:51:26 UTC (rev 167)
@@ -27,11 +27,10 @@
[TearDown]
public void TearDown()
{
- if (parser != null)
- {
- parser.Dispose();
- parser = null;
- }
+ if (parser == null) return;
+
+ parser.Dispose();
+ parser = null;
}
}
@@ -91,7 +90,7 @@
writer.Flush();
parser = new DumpFileParser(stream, "main");
- Byte[] code = parser.GetBytes();
+ var code = parser.GetBytes();
CollectionAssert.AreEqual(new Byte[] {0xc9, 0xc3, 0x90}, code);
}
@@ -114,7 +113,7 @@
}
[Test]
- [ExpectedException(typeof(FormatException))]
+ [ExpectedException(typeof (FormatException))]
public void LineWithBadHex()
{
writer.WriteLine(" 8048385: 83 ej 10 sub esp,0x10");
@@ -176,7 +175,7 @@
Assert.AreEqual(0x0804837c, parser.BaseAddress);
Assert.AreEqual(0x0804837d, parser.EntryPointAddress);
- Byte[] code = parser.GetBytes();
+ var code = parser.GetBytes();
CollectionAssert.AreEqual(new Byte[] {0xc9, 0xc3}, code);
Assert.AreEqual(2, code.Length);
Assert.AreEqual(0, parser.ExpectedReportItems.Count);
@@ -195,7 +194,7 @@
Assert.AreEqual(0x0804837c, parser.BaseAddress);
Assert.AreEqual(0x0804837d, parser.EntryPointAddress);
- Byte[] code = parser.GetBytes();
+ var code = parser.GetBytes();
CollectionAssert.AreEqual(new Byte[] {0xc9, 0xc3, 0x90}, code);
Assert.AreEqual(3, code.Length);
Assert.AreEqual(0, parser.ExpectedReportItems.Count);
@@ -224,7 +223,7 @@
Assert.AreEqual(0x0804837c, parser.BaseAddress);
Assert.AreEqual(0x0804837c, parser.EntryPointAddress);
- Byte[] code = parser.GetBytes();
+ var code = parser.GetBytes();
Assert.AreEqual(0xc9, code[0]);
}
Modified: ElfFileParser.cs
===================================================================
--- ElfFileParser.cs 2009-02-02 22:36:43 UTC (rev 166)
+++ ElfFileParser.cs 2009-02-12 03:51:26 UTC (rev 167)
@@ -22,6 +22,20 @@
textData = new Byte[stream.Length];
}
+ #region IDisposable Members
+
+ public void Dispose()
+ {
+ if (null != stream)
+ {
+ stream.Dispose();
+ }
+ }
+
+ #endregion
+
+ #region IParsable Members
+
public UInt32 BaseAddress
{
get { return 0x080482e0; }
@@ -40,16 +54,10 @@
public Byte[] GetBytes()
{
stream.Seek(0x2e0, SeekOrigin.Begin);
- stream.Read(textData, 0, (Int32)(stream.Length - stream.Position));
+ stream.Read(textData, 0, (Int32) (stream.Length - stream.Position));
return textData;
}
- public void Dispose()
- {
- if (null != stream)
- {
- stream.Dispose();
- }
- }
+ #endregion
}
}
\ No newline at end of file
Modified: ElfFileParserTest.cs
===================================================================
--- ElfFileParserTest.cs 2009-02-02 22:36:43 UTC (rev 166)
+++ ElfFileParserTest.cs 2009-02-12 03:51:26 UTC (rev 167)
@@ -38,7 +38,7 @@
[TestFixture]
public class WellFormatted : ElfFileParserFixture
{
- private Byte[] textData;
+ #region Setup/Teardown
[SetUp]
public override void SetUp()
@@ -52,6 +52,10 @@
parser = new ElfFileParser(stream);
}
+ #endregion
+
+ private Byte[] textData;
+
[Test]
public void GetBytes()
{
Modified: GLibcStartMainContract.cs
===================================================================
--- GLibcStartMainContract.cs 2009-02-02 22:36:43 UTC (rev 166)
+++ GLibcStartMainContract.cs 2009-02-12 03:51:26 UTC (rev 167)
@@ -8,21 +8,15 @@
namespace bugreport
{
- public class GLibcStartMainContract : Contract
+ internal sealed class GLibcStartMainContract : Contract
{
public override Boolean IsSatisfiedBy(MachineState state, Byte[] code)
{
- UInt32 effectiveAddress = Opcode.GetEffectiveAddress(code, state.InstructionPointer);
+ var effectiveAddress = Opcode.GetEffectiveAddress(code, state.InstructionPointer);
const UInt32 GLIBC_START_MAIN_IMPORT_FUNCTION_ADDR = 0x80482b8;
- if (effectiveAddress == GLIBC_START_MAIN_IMPORT_FUNCTION_ADDR)
- {
- return true;
- }
- else
- {
- return false;
- }
+
+ return effectiveAddress == GLIBC_START_MAIN_IMPORT_FUNCTION_ADDR;
}
public override MachineState Execute(MachineState state)
Modified: GLibcStartMainContractTest.cs
===================================================================
--- GLibcStartMainContractTest.cs 2009-02-02 22:36:43 UTC (rev 166)
+++ GLibcStartMainContractTest.cs 2009-02-12 03:51:26 UTC (rev 167)
@@ -12,8 +12,7 @@
[TestFixture]
public class GLibcStartMainContractTest
{
- private GLibcStartMainContract contract;
- private MachineState state;
+ #region Setup/Teardown
[SetUp]
public void SetUp()
@@ -24,6 +23,11 @@
contract = new GLibcStartMainContract();
}
+ #endregion
+
+ private GLibcStartMainContract contract;
+ private MachineState state;
+
[Test]
public void Execute()
{
Modified: InvalidOpcodeException.cs
===================================================================
--- InvalidOpcodeException.cs 2009-02-02 22:36:43 UTC (rev 166)
+++ InvalidOpcodeException.cs 2009-02-12 03:51:26 UTC (rev 167)
@@ -3,18 +3,18 @@
namespace bugreport
{
- public class InvalidOpcodeException : Exception
+ public sealed class InvalidOpcodeException : Exception
{
public InvalidOpcodeException(params Byte[] code)
: base(FormatOpcodes(code))
{
}
- public static String FormatOpcodes(params Byte[] code)
+ private static String FormatOpcodes(params Byte[] code)
{
var message = new StringBuilder("Invalid opcode: ");
- foreach (Byte opcode in code)
+ foreach (var opcode in code)
{
message.Append(String.Format(" 0x{0:x2}", opcode));
}
Modified: MachineState.cs
===================================================================
--- MachineState.cs 2009-02-02 22:36:43 UTC (rev 166)
+++ MachineState.cs 2009-02-12 03:51:26 UTC (rev 167)
@@ -33,7 +33,7 @@
public override Boolean Equals(object obj)
{
- var operationResult = (OperationResult)obj;
+ var operationResult = (OperationResult) obj;
return Value.Equals(operationResult.Value) && ZeroFlag == operationResult.ZeroFlag;
}
@@ -97,7 +97,7 @@
return registers[RegisterName.ESP].PointsTo[0];
}
- set
+ private set
{
Debug.Assert(registers[RegisterName.ESP] != null);
Debug.Assert(registers[RegisterName.ESP].PointsTo != null);
@@ -132,7 +132,7 @@
return false;
}
- foreach (UInt32 key in dataSegment.Keys)
+ foreach (var key in dataSegment.Keys)
{
if (!other.dataSegment.ContainsKey(key))
{
@@ -150,11 +150,11 @@
public override Int32 GetHashCode()
{
- Int32 hashCode = instructionPointer.GetHashCode() ^
- registers.GetHashCode() ^
- zeroFlag.GetHashCode();
+ var hashCode = instructionPointer.GetHashCode() ^
+ registers.GetHashCode() ^
+ zeroFlag.GetHashCode();
- foreach (UInt32 key in dataSegment.Keys)
+ foreach (var key in dataSegment.Keys)
{
hashCode ^= dataSegment[key].GetHashCode();
}
@@ -164,7 +164,7 @@
public MachineState PushOntoStack(AbstractValue value)
{
- MachineState newState = DoOperation(RegisterName.ESP, OperatorEffect.Add, new AbstractValue(0x4));
+ var newState = DoOperation(RegisterName.ESP, OperatorEffect.Add, new AbstractValue(0x4));
newState.TopOfStack = new AbstractValue(value);
return newState;
}
@@ -195,7 +195,7 @@
String.Format("Unsupported OperatorEffect: {0}", _operatorEffect), "_operatorEffect");
}
}
-
+
return newState;
}
@@ -208,11 +208,11 @@
case OperatorEffect.Assignment:
{
newState.dataSegment[offset] =
- newState.DoOperation(newState.dataSegment[offset], _operatorEffect, rhs).Value;
+ DoOperation(newState.dataSegment[offset], _operatorEffect, rhs).Value;
break;
}
}
-
+
return newState;
}
@@ -225,7 +225,7 @@
case OperatorEffect.Assignment:
case OperatorEffect.Cmp:
{
- OperationResult result = newState.DoOperation(Registers[lhs].PointsTo[index], _operatorEffect, rhs);
+ var result = DoOperation(Registers[lhs].PointsTo[index], _operatorEffect, rhs);
newState.Registers[lhs].PointsTo[index] = result.Value;
newState.ZeroFlag = result.ZeroFlag;
break;
@@ -241,12 +241,12 @@
if (Registers[lhs].IsPointer && _operatorEffect != OperatorEffect.Assignment)
{
- AbstractBuffer newBuffer = Registers[lhs].PointsTo.DoOperation(_operatorEffect, rhs);
+ var newBuffer = Registers[lhs].PointsTo.DoOperation(_operatorEffect, rhs);
newState.Registers[lhs] = new AbstractValue(newBuffer);
}
else
{
- OperationResult result = newState.DoOperation(Registers[lhs], _operatorEffect, rhs);
+ var result = DoOperation(Registers[lhs], _operatorEffect, rhs);
newState.Registers[lhs] = result.Value;
newState.ZeroFlag = result.ZeroFlag;
}
@@ -257,13 +257,13 @@
public MachineState DoOperation(RegisterName lhs, OperatorEffect _operatorEffect, RegisterName rhs)
{
var newState = new MachineState(this);
- OperationResult result = newState.DoOperation(Registers[lhs], _operatorEffect, Registers[rhs]);
+ var result = DoOperation(Registers[lhs], _operatorEffect, Registers[rhs]);
newState.Registers[lhs] = result.Value;
newState.ZeroFlag = result.ZeroFlag;
return newState;
}
- public OperationResult DoOperation(AbstractValue lhs, OperatorEffect _operatorEffect, AbstractValue rhs)
+ private static OperationResult DoOperation(AbstractValue lhs, OperatorEffect _operatorEffect, AbstractValue rhs)
{
if (rhs.IsPointer && _operatorEffect != OperatorEffect.Assignment)
{
@@ -272,7 +272,6 @@
var result = new OperationResult();
AbstractValue totalValue;
- UInt32 total;
if (_operatorEffect == OperatorEffect.Assignment)
{
@@ -289,14 +288,7 @@
if (_operatorEffect == OperatorEffect.Cmp)
{
- if ((lhs.Value - rhs.Value) == 0)
- {
- result.ZeroFlag = true;
- }
- else
- {
- result.ZeroFlag = false;
- }
+ result.ZeroFlag = (lhs.Value - rhs.Value) == 0;
totalValue = lhs;
result.Value = totalValue;
@@ -305,12 +297,12 @@
if (lhs.IsPointer)
{
- AbstractBuffer newBuffer = lhs.PointsTo.DoOperation(_operatorEffect, rhs);
+ var newBuffer = lhs.PointsTo.DoOperation(_operatorEffect, rhs);
result.Value = new AbstractValue(newBuffer);
return result;
}
- total = getCalculatedValue(lhs.Value, _operatorEffect, rhs.Value);
+ var total = getCalculatedValue(lhs.Value, _operatorEffect, rhs.Value);
totalValue = new AbstractValue(total);
if (lhs.IsTainted || rhs.IsTainted)
Modified: MachineStateTest.cs
===================================================================
--- MachineStateTest.cs 2009-02-02 22:36:43 UTC (rev 166)
+++ MachineStateTest.cs 2009-02-12 03:51:26 UTC (rev 167)
@@ -12,6 +12,12 @@
[TestFixture]
public class MachineStateTest
{
+ [SetUp]
+ public void SetUp()
+ {
+ state = new MachineState(new RegisterCollection());
+ }
+
private readonly AbstractValue one = new AbstractValue(1);
private readonly AbstractValue two = new AbstractValue(2).AddTaint();
private MachineState state;
@@ -33,12 +39,6 @@
set { state.Registers[RegisterName.ESP] = value; }
}
- [SetUp]
- public void SetUp()
- {
- state = new MachineState(new RegisterCollection());
- }
-
[Test]
public void Add()
{
@@ -75,8 +75,7 @@
[Test]
public void AssignmentRetainsOOB()
{
- var oob = new AbstractValue(1);
- oob.IsOOB = true;
+ var oob = new AbstractValue(1) {IsOOB = true};
state = state.DoOperation(RegisterName.EAX, OperatorEffect.Assignment, oob);
Assert.IsTrue(eax.IsOOB);
@@ -143,7 +142,7 @@
[Test]
public void Jnz()
{
- Byte offset = 6;
+ const byte offset = 6;
eax = two;
ebx = one;
state = state.DoOperation(RegisterName.EAX, OperatorEffect.Cmp, RegisterName.EAX);
@@ -156,7 +155,7 @@
}
[Test]
- [ExpectedException(typeof(ArgumentException))]
+ [ExpectedException(typeof (ArgumentException))]
public void JnzPointerOffset()
{
var pointer = new AbstractValue(AbstractValue.GetNewBuffer(1));
@@ -164,7 +163,7 @@
}
[Test]
- [ExpectedException(typeof(ArgumentException))]
+ [ExpectedException(typeof (ArgumentException))]
public void NonAssignmentOfPointer()
{
eax = one;
@@ -192,7 +191,7 @@
[Test]
public void PointerAdd()
{
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(0x10);
+ var buffer = AbstractValue.GetNewBuffer(0x10);
buffer[4] = one;
eax = new AbstractValue(buffer);
@@ -203,7 +202,7 @@
[Test]
public void PointerAnd()
{
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(0x10);
+ var buffer = AbstractValue.GetNewBuffer(0x10);
buffer[4] = one;
eax = new AbstractValue(buffer);
@@ -212,7 +211,7 @@
Assert.AreEqual(one, eax.PointsTo[0]);
var andValue = new AbstractValue(0xfffffff0);
- MachineState newState = state.DoOperation(RegisterName.EAX, OperatorEffect.And, andValue);
+ var newState = state.DoOperation(RegisterName.EAX, OperatorEffect.And, andValue);
Assert.AreNotSame(newState, state);
Assert.AreNotEqual(newState, state);
@@ -223,7 +222,7 @@
[Test]
public void PointerSub()
{
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(0x10);
+ var buffer = AbstractValue.GetNewBuffer(0x10);
buffer[0] = one;
eax = new AbstractValue(buffer);
ebx = new AbstractValue(0x4);
@@ -236,7 +235,7 @@
[Test]
public void PushPopThenAssignToTop()
{
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(0x20);
+ var buffer = AbstractValue.GetNewBuffer(0x20);
esp = new AbstractValue(buffer);
state = state.PushOntoStack(one);
@@ -249,7 +248,7 @@
[Test]
public void PushTwiceThenManuallyAdjustStack()
{
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(0x20);
+ var buffer = AbstractValue.GetNewBuffer(0x20);
esp = new AbstractValue(buffer);
state = state.PushOntoStack(one);
state = state.PushOntoStack(two);
@@ -281,7 +280,7 @@
}
[Test]
- [ExpectedException(typeof(ArgumentException))]
+ [ExpectedException(typeof (ArgumentException))]
public void Unknown()
{
state.DoOperation(RegisterName.EAX, OperatorEffect.Unknown, RegisterName.EBX);
Modified: Main.cs
===================================================================
--- Main.cs 2009-02-02 22:36:43 UTC (rev 166)
+++ Main.cs 2009-02-12 03:51:26 UTC (rev 167)
@@ -44,19 +44,21 @@
analyzeFiles(Options.Filenames, Options.IsTracing, Options.IsDebugging);
- if (analyzer.ExpectedReportItems.Count != 0 &&
- (analyzer.ExpectedReportItems.Count != analyzer.ActualReportItems.Count))
+ if (analyzer.ExpectedReportItems.Count == 0 ||
+ (analyzer.ExpectedRep...
[truncated message content] |
|
From: <mat...@us...> - 2009-02-02 22:37:24
|
Revision: 166
http://bugreport.svn.sourceforge.net/bugreport/?rev=166&view=rev
Author: matt_hargett
Date: 2009-02-02 22:36:43 +0000 (Mon, 02 Feb 2009)
Log Message:
-----------
FxCop ruleset for VS2010. I mainly turned off stupid naming requirements, some of which are actually discouraged in Framework Design Guidelines(!?) This may or may not work with FxCop 1.36; let me know either way.
Added Paths:
-----------
bugreport.fxcop.ruleset
Added: bugreport.fxcop.ruleset
===================================================================
--- bugreport.fxcop.ruleset (rev 0)
+++ bugreport.fxcop.ruleset 2009-02-02 22:36:43 UTC (rev 166)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RuleSet Name="Copy of Microsoft Extended Design Guideline Rules" Description="These rules expand on the basic design guideline rules to maximize the usability and maintainability issues that are reported. Extra emphasis is placed on naming guidelines. Consider including this rule set if your project includes library code or if you want to enforce the highest standards for writing maintainable code." ToolsVersion="10.0">
+ <Localization ResourceAssembly="Microsoft.VisualStudio.CodeAnalysis.RuleSets.Strings.dll" ResourceBaseName="Microsoft.VisualStudio.CodeAnalysis.RuleSets.Strings.Localized">
+ <Name Resource="ExtendedDesignGuidelineRules_Name" />
+ <Description Resource="ExtendedDesignGuidelineRules_Description" />
+ </Localization>
+ <Include Path="basicdesignguidelinerules.ruleset" Action="Default" />
+ <Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
+ <Rule Id="CA1014" Action="None" />
+ <Rule Id="CA1016" Action="None" />
+ <Rule Id="CA1017" Action="None" />
+ <Rule Id="CA1020" Action="Warn" />
+ <Rule Id="CA1021" Action="Warn" />
+ <Rule Id="CA1040" Action="Warn" />
+ <Rule Id="CA1045" Action="Warn" />
+ <Rule Id="CA1062" Action="Warn" />
+ <Rule Id="CA1301" Action="None" />
+ <Rule Id="CA1501" Action="Warn" />
+ <Rule Id="CA1504" Action="Warn" />
+ <Rule Id="CA1505" Action="Warn" />
+ <Rule Id="CA1506" Action="Warn" />
+ <Rule Id="CA1700" Action="Warn" />
+ <Rule Id="CA1712" Action="Warn" />
+ <Rule Id="CA1713" Action="Warn" />
+ <Rule Id="CA1714" Action="Warn" />
+ <Rule Id="CA1717" Action="Warn" />
+ <Rule Id="CA1719" Action="Warn" />
+ <Rule Id="CA1720" Action="Warn" />
+ <Rule Id="CA1721" Action="Warn" />
+ <Rule Id="CA1722" Action="Warn" />
+ <Rule Id="CA1724" Action="Warn" />
+ <Rule Id="CA1725" Action="Warn" />
+ <Rule Id="CA2101" Action="None" />
+ </Rules>
+</RuleSet>
\ No newline at end of file
Property changes on: bugreport.fxcop.ruleset
___________________________________________________________________
Added: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mat...@us...> - 2009-01-29 22:41:13
|
Revision: 165
http://bugreport.svn.sourceforge.net/bugreport/?rev=165&view=rev
Author: matt_hargett
Date: 2009-01-29 21:45:15 +0000 (Thu, 29 Jan 2009)
Log Message:
-----------
Matt - fix all the StyleCop warnings that are easy/relevant.
Modified Paths:
--------------
AbstractBuffer.cs
AbstractBufferTest.cs
AbstractValue.cs
AbstractValueTest.cs
AnalysisEngine.csproj
Analyzer.cs
AnalyzerTest.cs
AssemblyInfo.cs
BitMath.cs
BitMathTest.cs
Contract.cs
DebuggerCommand.cs
DebuggerCommandTest.cs
DebuggerView.cs
DumpFileParser.cs
DumpFileParserTest.cs
ElfFileParser.cs
ElfFileParserTest.cs
GLibcStartMainContract.cs
GLibcStartMainContractTest.cs
MachineState.cs
MachineStateTest.cs
Main.cs
MainTest.cs
MallocContract.cs
ModRM.cs
ModRMTest.cs
Opcode.cs
OpcodeFormatter.cs
OpcodeFormatterTest.cs
Options.cs
OptionsTest.cs
RegisterCollection.cs
RegisterCollectionTest.cs
ReportItem.cs
SIB.cs
SIBTests.cs
X86Emulator.cs
X86EmulatorTest.cs
X86Opcode.cs
X86OpcodeTest.cs
bugreport.sln
Added Paths:
-----------
InvalidOpcodeException.cs
Modified: AbstractBuffer.cs
===================================================================
--- AbstractBuffer.cs 2009-01-29 05:41:37 UTC (rev 164)
+++ AbstractBuffer.cs 2009-01-29 21:45:15 UTC (rev 165)
@@ -1,33 +1,43 @@
-// This file is part of bugreport.
-// Copyright (c) 2006-2009 The bugreport Developers.
-// See AUTHORS.txt for details.
-// Licensed under the GNU General Public License, Version 3 (GPLv3).
-// See LICENSE.txt for details.
-
+// This file is part of bugreport.
+// Copyright (c) 2006-2009 The bugreport Developers.
+// See AUTHORS.txt for details.
+// Licensed under the GNU General Public License, Version 3 (GPLv3).
+// See LICENSE.txt for details.
+
using System;
-namespace bugreport
-{
- public class AbstractBuffer
+namespace bugreport
+{
+ public class AbstractBuffer
{
- private readonly Int32 allocatedLength;
+ private readonly Int32 allocatedLength;
private UInt32 baseIndex;
- private AbstractValue[] storage;
-
- public AbstractBuffer(AbstractValue[] _buffer)
- {
- storage = _buffer;
- allocatedLength = storage.Length;
- }
-
- public AbstractBuffer(AbstractBuffer _copyMe)
- {
- baseIndex = _copyMe.BaseIndex;
- allocatedLength = _copyMe.allocatedLength;
- storage = new AbstractValue[_copyMe.storage.Length];
- Array.Copy(_copyMe.storage, storage, _copyMe.storage.Length);
+ private AbstractValue[] storage;
+
+ public AbstractBuffer(AbstractValue[] _buffer)
+ {
+ storage = _buffer;
+ allocatedLength = storage.Length;
}
+ public AbstractBuffer(AbstractBuffer _copyMe)
+ {
+ baseIndex = _copyMe.BaseIndex;
+ allocatedLength = _copyMe.allocatedLength;
+ storage = new AbstractValue[_copyMe.storage.Length];
+ Array.Copy(_copyMe.storage, storage, _copyMe.storage.Length);
+ }
+
+ public UInt32 BaseIndex
+ {
+ get { return baseIndex; }
+ }
+
+ public Int32 Length
+ {
+ get { return allocatedLength; }
+ }
+
public AbstractValue this[Int32 index]
{
get
@@ -61,72 +71,64 @@
}
}
- public UInt32 BaseIndex
+ public AbstractBuffer DoOperation(OperatorEffect _operatorEffect, AbstractValue _rhs)
{
- get { return baseIndex; }
- }
+ AbstractBuffer lhs = this;
- public Int32 Length
- {
- get { return allocatedLength; }
- }
-
- public AbstractBuffer DoOperation(OperatorEffect _operatorEffect, AbstractValue _rhs)
- {
- AbstractBuffer lhs = this;
-
- // TODO: should have a guard for if _rhs isnt a pointer
-
- switch (_operatorEffect)
- {
- case OperatorEffect.Assignment:
- {
- var result = new AbstractBuffer(lhs);
-
- return result;
- }
-
- case OperatorEffect.Add:
- {
- var result = new AbstractBuffer(lhs);
- result.baseIndex += _rhs.Value;
-
- return result;
- }
-
- case OperatorEffect.Sub:
- {
- var result = new AbstractBuffer(lhs);
-
- if (result.baseIndex < _rhs.Value)
- {
+ // TODO: should have a guard for if _rhs isn't a pointer
+ switch (_operatorEffect)
+ {
+ case OperatorEffect.Assignment:
+ {
+ var result = new AbstractBuffer(lhs);
+
+ return result;
+ }
+
+ case OperatorEffect.Add:
+ {
+ var result = new AbstractBuffer(lhs);
+ result.baseIndex += _rhs.Value;
+
+ return result;
+ }
+
+ case OperatorEffect.Sub:
+ {
+ var result = new AbstractBuffer(lhs);
+
+ if (result.baseIndex < _rhs.Value)
+ {
throw new ArgumentOutOfRangeException(
String.Format(
"Attempting to set a negative baseindex, baseindex: {0:x4}, _subValue {1:x4}",
- result.baseIndex, _rhs.Value));
- }
-
- result.baseIndex -= _rhs.Value;
- return result;
- }
-
- case OperatorEffect.And:
- {
- var result = new AbstractBuffer(lhs);
-
- result.baseIndex &= _rhs.Value;
- return result;
- }
-
- default:
+ result.baseIndex,
+ _rhs.Value
+ )
+ );
+ }
+
+ result.baseIndex -= _rhs.Value;
+ return result;
+ }
+
+ case OperatorEffect.And:
+ {
+ var result = new AbstractBuffer(lhs);
+
+ result.baseIndex &= _rhs.Value;
+ return result;
+ }
+
+ default:
throw new ArgumentException(
- String.Format("Unsupported OperatorEffect: {0}", _operatorEffect), "_operatorEffect");
- }
+ String.Format("Unsupported OperatorEffect: {0}", _operatorEffect), "_operatorEffect");
+ }
}
- private Boolean IsIndexPastBounds(Int32 index)
- {
- return (((baseIndex + index) >= allocatedLength) && ((baseIndex + index) >= storage.Length));
+ private Boolean IsIndexPastBounds(Int32 index)
+ {
+ return ((baseIndex + index) >= allocatedLength) && ((baseIndex + index) >= storage.Length);
}
private void extend(UInt32 _newLength)
@@ -153,6 +155,6 @@
}
return;
- }
- }
+ }
+ }
}
\ No newline at end of file
Modified: AbstractBufferTest.cs
===================================================================
--- AbstractBufferTest.cs 2009-01-29 05:41:37 UTC (rev 164)
+++ AbstractBufferTest.cs 2009-01-29 21:45:15 UTC (rev 165)
@@ -1,216 +1,216 @@
-// This file is part of bugreport.
-// Copyright (c) 2006-2009 The bugreport Developers.
-// See AUTHORS.txt for details.
-// Licensed under the GNU General Public License, Version 3 (GPLv3).
-// See LICENSE.txt for details.
-
+// This file is part of bugreport.
+// Copyright (c) 2006-2009 The bugreport Developers.
+// See AUTHORS.txt for details.
+// Licensed under the GNU General Public License, Version 3 (GPLv3).
+// See LICENSE.txt for details.
+
using System;
using NUnit.Framework;
-namespace bugreport
-{
- [TestFixture]
- public class AbstractBufferTest
+namespace bugreport
+{
+ [TestFixture]
+ public class AbstractBufferTest
{
- [Test]
- public void Copy()
- {
- AbstractValue[] values = AbstractValue.GetNewBuffer(4);
- var buffer = new AbstractBuffer(values);
- var newBuffer = new AbstractBuffer(buffer);
- Assert.AreNotSame(newBuffer, buffer);
-
- for (Int32 index = 0; index < newBuffer.Length; index++)
- {
- Assert.AreSame(newBuffer[index], buffer[index]);
- }
+ [Test]
+ public void Copy()
+ {
+ AbstractValue[] values = AbstractValue.GetNewBuffer(4);
+ var buffer = new AbstractBuffer(values);
+ var newBuffer = new AbstractBuffer(buffer);
+ Assert.AreNotSame(newBuffer, buffer);
+
+ for (Int32 index = 0; index < newBuffer.Length; index++)
+ {
+ Assert.AreSame(newBuffer[index], buffer[index]);
+ }
}
- [Test]
- [ExpectedException(typeof (ArgumentOutOfRangeException))]
- public void InvalidPointerAnd()
- {
- var one = new AbstractValue(0x1);
- var buffer = new AbstractBuffer(new[] {one});
- AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Sub, new AbstractValue(3));
- modifiedBuffer.DoOperation(OperatorEffect.And, new AbstractValue(0xf));
+ [Test]
+ [ExpectedException(typeof(ArgumentOutOfRangeException))]
+ public void InvalidPointerAnd()
+ {
+ var one = new AbstractValue(0x1);
+ var buffer = new AbstractBuffer(new[] {one});
+ AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Sub, new AbstractValue(3));
+ modifiedBuffer.DoOperation(OperatorEffect.And, new AbstractValue(0xf));
}
- [Test]
- public void OverflowDoesntLoseIncrement()
- {
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
- var pointer = new AbstractBuffer(buffer);
- var value = new AbstractValue(0x41);
- value = value.AddTaint();
-
- pointer[0] = value;
-
- pointer = pointer.DoOperation(OperatorEffect.Add, new AbstractValue(1));
-
- pointer[16] = value;
-
- pointer = pointer.DoOperation(OperatorEffect.Sub, new AbstractValue(1));
-
- Assert.AreEqual(0x41, pointer[0].Value);
- Assert.IsTrue(value.IsTainted);
- Assert.AreEqual(0x41, pointer[17].Value);
- Assert.IsTrue(pointer[17].IsTainted);
- }
-
- [Test]
- public void OverflowZeroSizeBuffer()
- {
- var f = new AbstractBuffer(new AbstractValue[] {});
- Assert.IsFalse(f[0].IsInitialized);
- }
-
- [Test]
- public void PointerAdd()
- {
- var one = new AbstractValue(0x1);
- var two = new AbstractValue(0x2);
- var three = new AbstractValue(0x3);
- var four = new AbstractValue(0x4);
- AbstractValue[] values = AbstractValue.GetNewBuffer(4);
-
- values[0] = one;
- values[1] = two;
- values[2] = three;
- values[3] = four;
-
- var buffer = new AbstractBuffer(values);
- Assert.AreEqual(one, buffer[0]);
- AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(2));
- Assert.AreEqual(three, modifiedBuffer[0]);
- }
-
- [Test]
- public void PointerAnd()
- {
- var one = new AbstractValue(0x1);
- var two = new AbstractValue(0x2);
- var three = new AbstractValue(0x3);
- var four = new AbstractValue(0x4);
- AbstractValue[] avBuffer = AbstractValue.GetNewBuffer(4);
-
- avBuffer[0] = one;
- avBuffer[1] = two;
- avBuffer[2] = three;
- avBuffer[3] = four;
-
- var buffer = new AbstractBuffer(avBuffer);
- Assert.AreEqual(one, buffer[0]);
- AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(3));
- Assert.AreEqual(four, modifiedBuffer[0]);
- AbstractBuffer andedBuffer = modifiedBuffer.DoOperation(OperatorEffect.And, new AbstractValue(0xfffffff0));
- Assert.AreEqual(one, andedBuffer[0]);
+ [Test]
+ public void OverflowDoesntLoseIncrement()
+ {
+ AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
+ var pointer = new AbstractBuffer(buffer);
+ var value = new AbstractValue(0x41);
+ value = value.AddTaint();
+
+ pointer[0] = value;
+
+ pointer = pointer.DoOperation(OperatorEffect.Add, new AbstractValue(1));
+
+ pointer[16] = value;
+
+ pointer = pointer.DoOperation(OperatorEffect.Sub, new AbstractValue(1));
+
+ Assert.AreEqual(0x41, pointer[0].Value);
+ Assert.IsTrue(value.IsTainted);
+ Assert.AreEqual(0x41, pointer[17].Value);
+ Assert.IsTrue(pointer[17].IsTainted);
}
- [Test]
- public void PointerAssignment()
- {
- AbstractValue[] values = AbstractValue.GetNewBuffer(4);
- var buffer = new AbstractBuffer(values);
- AbstractBuffer assignedBuffer = buffer.DoOperation(OperatorEffect.Assignment, null);
- Assert.AreNotSame(buffer, assignedBuffer);
- }
-
- [Test]
- public void PointerOverflowByOne()
- {
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
- var pointer = new AbstractBuffer(buffer);
-
- AbstractValue value = pointer[16];
- Assert.IsTrue(value.IsOOB);
- Assert.IsFalse(value.IsInitialized);
- Assert.AreEqual(AbstractValue.UNKNOWN, value.Value);
- }
-
- [Test]
- public void PointerOverflowStillRetainsOldValues()
- {
- var test1 = new AbstractValue(0x41);
- var test2 = new AbstractValue(0x42);
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(2);
-
- buffer[0] = test1;
- buffer[1] = test2;
-
- var pointer = new AbstractBuffer(buffer);
-
- // Accessing pointer[2] will cause the AbstractBuffer to extend..
- Assert.IsTrue(pointer[2].IsOOB, " value is not out of bounds");
- Assert.IsFalse(pointer[2].IsInitialized);
- Assert.AreEqual(AbstractValue.UNKNOWN, pointer[2].Value);
-
- // And then we make sure the in bounds values stay the same
- Assert.IsFalse(pointer[0].IsOOB);
- Assert.IsFalse(pointer[1].IsOOB);
-
- Assert.AreEqual(0x41, pointer[0].Value);
- Assert.AreEqual(0x42, pointer[1].Value);
- }
-
- [Test]
- public void PointerOverflowTwiceStillRetainsOriginalValues()
- {
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
- var pointer = new AbstractBuffer(buffer);
-
- //Access beyond buffer bounds forcing buffer to expand
- Assert.IsTrue(pointer[17].IsOOB);
- Assert.IsFalse(pointer[17].IsInitialized);
- Assert.AreEqual(AbstractValue.UNKNOWN, pointer[17].Value);
-
- pointer[17] = new AbstractValue(0x41414141);
-
- // Access beyond previously expanded bounds to force 2nd expand
- Assert.IsTrue(pointer[64].IsOOB);
- Assert.IsFalse(pointer[64].IsInitialized);
- Assert.AreEqual(AbstractValue.UNKNOWN, pointer[64].Value);
-
- // check that value set outside of bounds is still the same as well
- Assert.IsTrue(pointer[17].IsOOB);
- Assert.AreEqual(0x41414141, pointer[17].Value);
+ [Test]
+ public void OverflowZeroSizeBuffer()
+ {
+ var f = new AbstractBuffer(new AbstractValue[] {});
+ Assert.IsFalse(f[0].IsInitialized);
}
- [Test]
- public void PointerSub()
- {
- var one = new AbstractValue(0x1);
- var two = new AbstractValue(0x2);
- var three = new AbstractValue(0x3);
- var four = new AbstractValue(0x4);
- AbstractValue[] values = AbstractValue.GetNewBuffer(4);
-
- values[0] = one;
- values[1] = two;
- values[2] = three;
- values[3] = four;
-
- var buffer = new AbstractBuffer(values);
- Assert.AreEqual(one, buffer[0]);
- AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(2));
- Assert.AreEqual(three, modifiedBuffer[0]);
-
- AbstractBuffer subbedBuffer = modifiedBuffer.DoOperation(OperatorEffect.Sub, new AbstractValue(2));
- Assert.AreEqual(one, subbedBuffer[0]);
- }
-
- [Test]
- [ExpectedException(typeof (ArgumentOutOfRangeException))]
- public void PointerSubUnderflow()
- {
- new AbstractBuffer(new AbstractValue[] {}).DoOperation(OperatorEffect.Sub, new AbstractValue(1));
+ [Test]
+ public void PointerAdd()
+ {
+ var one = new AbstractValue(0x1);
+ var two = new AbstractValue(0x2);
+ var three = new AbstractValue(0x3);
+ var four = new AbstractValue(0x4);
+ AbstractValue[] values = AbstractValue.GetNewBuffer(4);
+
+ values[0] = one;
+ values[1] = two;
+ values[2] = three;
+ values[3] = four;
+
+ var buffer = new AbstractBuffer(values);
+ Assert.AreEqual(one, buffer[0]);
+ AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(2));
+ Assert.AreEqual(three, modifiedBuffer[0]);
}
- [Test]
- [ExpectedException(typeof (ArgumentException))]
- public void PointerUnknownOperation()
- {
- new AbstractBuffer(new AbstractValue[] {}).DoOperation(OperatorEffect.Unknown, null);
+ [Test]
+ public void PointerAnd()
+ {
+ var one = new AbstractValue(0x1);
+ var two = new AbstractValue(0x2);
+ var three = new AbstractValue(0x3);
+ var four = new AbstractValue(0x4);
+ AbstractValue[] values = AbstractValue.GetNewBuffer(4);
+
+ values[0] = one;
+ values[1] = two;
+ values[2] = three;
+ values[3] = four;
+
+ var buffer = new AbstractBuffer(values);
+ Assert.AreEqual(one, buffer[0]);
+ AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(3));
+ Assert.AreEqual(four, modifiedBuffer[0]);
+ AbstractBuffer andedBuffer = modifiedBuffer.DoOperation(OperatorEffect.And, new AbstractValue(0xfffffff0));
+ Assert.AreEqual(one, andedBuffer[0]);
}
- }
+
+ [Test]
+ public void PointerAssignment()
+ {
+ AbstractValue[] values = AbstractValue.GetNewBuffer(4);
+ var buffer = new AbstractBuffer(values);
+ AbstractBuffer assignedBuffer = buffer.DoOperation(OperatorEffect.Assignment, null);
+ Assert.AreNotSame(buffer, assignedBuffer);
+ }
+
+ [Test]
+ public void PointerOverflowByOne()
+ {
+ AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
+ var pointer = new AbstractBuffer(buffer);
+
+ AbstractValue value = pointer[16];
+ Assert.IsTrue(value.IsOOB);
+ Assert.IsFalse(value.IsInitialized);
+ Assert.AreEqual(AbstractValue.UNKNOWN, value.Value);
+ }
+
+ [Test]
+ public void PointerOverflowStillRetainsOldValues()
+ {
+ var test1 = new AbstractValue(0x41);
+ var test2 = new AbstractValue(0x42);
+ AbstractValue[] buffer = AbstractValue.GetNewBuffer(2);
+
+ buffer[0] = test1;
+ buffer[1] = test2;
+
+ var pointer = new AbstractBuffer(buffer);
+
+ // Accessing pointer[2] will cause the AbstractBuffer to extend..
+ Assert.IsTrue(pointer[2].IsOOB, " value is not out of bounds");
+ Assert.IsFalse(pointer[2].IsInitialized);
+ Assert.AreEqual(AbstractValue.UNKNOWN, pointer[2].Value);
+
+ // And then we make sure the in bounds values stay the same
+ Assert.IsFalse(pointer[0].IsOOB);
+ Assert.IsFalse(pointer[1].IsOOB);
+
+ Assert.AreEqual(0x41, pointer[0].Value);
+ Assert.AreEqual(0x42, pointer[1].Value);
+ }
+
+ [Test]
+ public void PointerOverflowTwiceStillRetainsOriginalValues()
+ {
+ AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
+ var pointer = new AbstractBuffer(buffer);
+
+ // Access beyond buffer bounds forcing buffer to expand
+ Assert.IsTrue(pointer[17].IsOOB);
+ Assert.IsFalse(pointer[17].IsInitialized);
+ Assert.AreEqual(AbstractValue.UNKNOWN, pointer[17].Value);
+
+ pointer[17] = new AbstractValue(0x41414141);
+
+ // Access beyond previously expanded bounds to force 2nd expand
+ Assert.IsTrue(pointer[64].IsOOB);
+ Assert.IsFalse(pointer[64].IsInitialized);
+ Assert.AreEqual(AbstractValue.UNKNOWN, pointer[64].Value);
+
+ // check that value set outside of bounds is still the same as well
+ Assert.IsTrue(pointer[17].IsOOB);
+ Assert.AreEqual(0x41414141, pointer[17].Value);
+ }
+
+ [Test]
+ public void PointerSub()
+ {
+ var one = new AbstractValue(0x1);
+ var two = new AbstractValue(0x2);
+ var three = new AbstractValue(0x3);
+ var four = new AbstractValue(0x4);
+ AbstractValue[] values = AbstractValue.GetNewBuffer(4);
+
+ values[0] = one;
+ values[1] = two;
+ values[2] = three;
+ values[3] = four;
+
+ var buffer = new AbstractBuffer(values);
+ Assert.AreEqual(one, buffer[0]);
+ AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(2));
+ Assert.AreEqual(three, modifiedBuffer[0]);
+
+ AbstractBuffer subbedBuffer = modifiedBuffer.DoOperation(OperatorEffect.Sub, new AbstractValue(2));
+ Assert.AreEqual(one, subbedBuffer[0]);
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentOutOfRangeException))]
+ public void PointerSubUnderflow()
+ {
+ new AbstractBuffer(new AbstractValue[] {}).DoOperation(OperatorEffect.Sub, new AbstractValue(1));
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void PointerUnknownOperation()
+ {
+ new AbstractBuffer(new AbstractValue[] {}).DoOperation(OperatorEffect.Unknown, null);
+ }
+ }
}
\ No newline at end of file
Modified: AbstractValue.cs
===================================================================
--- AbstractValue.cs 2009-01-29 05:41:37 UTC (rev 164)
+++ AbstractValue.cs 2009-01-29 21:45:15 UTC (rev 165)
@@ -1,220 +1,223 @@
-// This file is part of bugreport.
-// Copyright (c) 2006-2009 The bugreport Developers.
-// See AUTHORS.txt for details.
-// Licensed under the GNU General Public License, Version 3 (GPLv3).
-// See LICENSE.txt for details.
-
+// This file is part of bugreport.
+// Copyright (c) 2006-2009 The bugreport Developers.
+// See AUTHORS.txt for details.
+// Licensed under the GNU General Public License, Version 3 (GPLv3).
+// See LICENSE.txt for details.
+
using System;
using System.Text;
-namespace bugreport
-{
- public class AbstractValue
- {
+namespace bugreport
+{
+ public class AbstractValue
+ {
public const UInt32 MAX_BUFFER_SIZE = 25600000;
public const UInt32 UNKNOWN = 0xb4dc0d3d;
- private readonly AbstractBuffer pointsTo;
- private readonly UInt32 storage;
- private Boolean tainted;
-
- public AbstractValue()
- {
- storage = UNKNOWN;
- }
-
- public AbstractValue(AbstractValue[] _willPointTo)
- {
- if (_willPointTo.Length == 0)
- {
- throw new ArgumentException("Empty buffer is not allowed", "_willPointTo");
- }
-
- storage = 0xdeadbeef;
- pointsTo = new AbstractBuffer(_willPointTo);
- }
-
- public AbstractValue(AbstractBuffer _willPointTo)
- {
- if (_willPointTo.Length == 0)
- {
- throw new ArgumentException("Empty buffer is not allowed", "_willPointTo");
- }
-
- storage = 0xdeadbeef;
- pointsTo = new AbstractBuffer(_willPointTo);
- }
-
- public AbstractValue(AbstractValue _copyMe)
- {
- if (_copyMe == null)
- {
- throw new ArgumentNullException("_copyMe");
- }
-
- storage = _copyMe.Value;
- tainted = _copyMe.IsTainted;
- IsOOB = _copyMe.IsOOB;
-
- if (_copyMe.PointsTo != null)
- {
- pointsTo = new AbstractBuffer(_copyMe.PointsTo);
- }
- }
-
- public AbstractValue(UInt32 _value)
- {
- storage = _value;
- }
-
- public AbstractBuffer PointsTo
- {
- get { return pointsTo; }
- }
-
- public Boolean IsTainted
- {
- get { return tainted; }
-
- private set { tainted = value; }
- }
-
- public Boolean IsOOB { get; set; }
-
- public Boolean IsInitialized
- {
- get { return storage != UNKNOWN; }
- }
-
- public UInt32 Value
- {
- get { return storage; }
- }
-
- public Boolean IsPointer
- {
- get { return pointsTo != null; }
+ private readonly AbstractBuffer pointsTo;
+ private readonly UInt32 storage;
+ private Boolean tainted;
+
+ public AbstractValue()
+ {
+ storage = UNKNOWN;
}
- public override Boolean Equals(object obj)
- {
- var other = obj as AbstractValue;
-
- if (null == other)
- {
- return false;
- }
-
- return Value == other.Value &&
- IsOOB == other.IsOOB &&
- IsTainted == other.IsTainted &&
- PointsTo == other.PointsTo;
- }
-
- public override Int32 GetHashCode()
- {
- Int32 hashCode = Value.GetHashCode() ^ IsOOB.GetHashCode() ^
- IsTainted.GetHashCode();
-
- if (PointsTo != null)
- {
- hashCode ^= PointsTo.GetHashCode();
- }
-
- return hashCode;
- }
-
- public static AbstractValue[] GetNewBuffer(UInt32 size)
- {
- if (size > MAX_BUFFER_SIZE)
- {
+ public AbstractValue(AbstractValue[] _willPointTo)
+ {
+ if (_willPointTo.Length == 0)
+ {
+ throw new ArgumentException("Empty buffer is not allowed", "_willPointTo");
+ }
+
+ storage = 0xdeadbeef;
+ pointsTo = new AbstractBuffer(_willPointTo);
+ }
+
+ public AbstractValue(AbstractBuffer _willPointTo)
+ {
+ if (_willPointTo.Length == 0)
+ {
+ throw new ArgumentException("Empty buffer is not allowed", "_willPointTo");
+ }
+
+ storage = 0xdeadbeef;
+ pointsTo = new AbstractBuffer(_willPointTo);
+ }
+
+ public AbstractValue(AbstractValue _copyMe)
+ {
+ if (_copyMe == null)
+ {
+ throw new ArgumentNullException("_copyMe");
+ }
+
+ storage = _copyMe.Value;
+ tainted = _copyMe.IsTainted;
+ IsOOB = _copyMe.IsOOB;
+
+ if (_copyMe.PointsTo != null)
+ {
+ pointsTo = new AbstractBuffer(_copyMe.PointsTo);
+ }
+ }
+
+ public AbstractValue(UInt32 _value)
+ {
+ storage = _value;
+ }
+
+ public AbstractBuffer PointsTo
+ {
+ get { return pointsTo; }
+ }
+
+ public Boolean IsTainted
+ {
+ get { return tainted; }
+
+ private set { tainted = value; }
+ }
+
+ public Boolean IsOOB { get; set; }
+
+ public Boolean IsInitialized
+ {
+ get { return storage != UNKNOWN; }
+ }
+
+ public UInt32 Value
+ {
+ get { return storage; }
+ }
+
+ public Boolean IsPointer
+ {
+ get { return pointsTo != null; }
+ }
+
+ public static AbstractValue[] GetNewBuffer(UInt32 size)
+ {
+ if (size > MAX_BUFFER_SIZE)
+ {
throw new ArgumentOutOfRangeException(
- "size", "Size specified larger than maximum allowed: " + MAX_BUFFER_SIZE);
- }
-
- var buffer = new AbstractValue[size];
- for (UInt32 i = 0; i < size; i++)
- {
- buffer[i] = new AbstractValue();
- }
-
- return buffer;
- }
-
- public AbstractValue TruncateValueToByte()
- {
- UInt32 byteValue = Value & 0xff;
- var truncatedValue = new AbstractValue(byteValue);
- truncatedValue.IsTainted = IsTainted;
-
- return truncatedValue;
- }
-
- public AbstractValue AddTaint()
- {
- if (PointsTo != null)
- {
- throw new InvalidOperationException("Cannot AddTaint to a pointer");
- }
-
- var taintedValue = new AbstractValue(this);
- taintedValue.IsTainted = true;
- return taintedValue;
- }
-
- public AbstractValue AddTaintIf(Boolean condition)
- {
- if (condition)
- {
- return AddTaint();
- }
-
- return this;
- }
-
- public override String ToString()
- {
- String result = String.Empty;
-
- if (tainted)
- result += "t";
-
- UInt32 valueToPrint = Value;
-
- if (pointsTo != null)
- {
- AbstractValue pointer = pointsTo[0];
-
- var newResult = new StringBuilder(result);
-
- const Byte maximumPointerDepth = 100;
- Int32 count = maximumPointerDepth;
- while ((pointer != null) && (count-- > 0))
- {
- newResult.Append("*");
-
- if (pointer.PointsTo != null)
- {
- pointer = pointer.PointsTo[0];
- }
- else
- {
- valueToPrint = pointer.Value;
- pointer = null;
- }
- }
- result = newResult.ToString();
- }
-
- if (valueToPrint != UNKNOWN)
- {
- result += String.Format("0x{0:x8}", valueToPrint);
- }
- else
- {
- result += "?";
- }
-
- return result;
- }
- }
+ "size", "Size specified larger than maximum allowed: " + MAX_BUFFER_SIZE);
+ }
+
+ var buffer = new AbstractValue[size];
+ for (UInt32 i = 0; i < size; i++)
+ {
+ buffer[i] = new AbstractValue();
+ }
+
+ return buffer;
+ }
+
+ public override Boolean Equals(object obj)
+ {
+ var other = obj as AbstractValue;
+
+ if (null == other)
+ {
+ return false;
+ }
+
+ return Value == other.Value &&
+ IsOOB == other.IsOOB &&
+ IsTainted == other.IsTainted &&
+ PointsTo == other.PointsTo;
+ }
+
+ public override Int32 GetHashCode()
+ {
+ Int32 hashCode = Value.GetHashCode() ^ IsOOB.GetHashCode() ^
+ IsTainted.GetHashCode();
+
+ if (PointsTo != null)
+ {
+ hashCode ^= PointsTo.GetHashCode();
+ }
+
+ return hashCode;
+ }
+
+ public AbstractValue TruncateValueToByte()
+ {
+ UInt32 byteValue = Value & 0xff;
+ var truncatedValue = new AbstractValue(byteValue);
+ truncatedValue.IsTainted = IsTainted;
+
+ return truncatedValue;
+ }
+
+ public AbstractValue AddTaint()
+ {
+ if (PointsTo != null)
+ {
+ throw new InvalidOperationException("Cannot AddTaint to a pointer");
+ }
+
+ var taintedValue = new AbstractValue(this);
+ taintedValue.IsTainted = true;
+ return taintedValue;
+ }
+
+ public AbstractValue AddTaintIf(Boolean condition)
+ {
+ if (condition)
+ {
+ return AddTaint();
+ }
+
+ return this;
+ }
+
+ public override String ToString()
+ {
+ String result = String.Empty;
+
+ if (tainted)
+ {
+ result += "t";
+ }
+
+ UInt32 valueToPrint = Value;
+
+ if (pointsTo != null)
+ {
+ AbstractValue pointer = pointsTo[0];
+
+ var newResult = new StringBuilder(result);
+
+ const Byte MAXIMUM_DISPLAYED_POINTER_DEPTH = 100;
+ Int32 count = MAXIMUM_DISPLAYED_POINTER_DEPTH;
+ while ((pointer != null) && (count-- > 0))
+ {
+ newResult.Append("*");
+
+ if (pointer.PointsTo != null)
+ {
+ pointer = pointer.PointsTo[0];
+ }
+ else
+ {
+ valueToPrint = pointer.Value;
+ pointer = null;
+ }
+ }
+
+ result = newResult.ToString();
+ }
+
+ if (valueToPrint != UNKNOWN)
+ {
+ result += String.Format("0x{0:x8}", valueToPrint);
+ }
+ else
+ {
+ result += "?";
+ }
+
+ return result;
+ }
+ }
}
\ No newline at end of file
Modified: AbstractValueTest.cs
===================================================================
--- AbstractValueTest.cs 2009-01-29 05:41:37 UTC (rev 164)
+++ AbstractValueTest.cs 2009-01-29 21:45:15 UTC (rev 165)
@@ -1,202 +1,202 @@
-// This file is part of bugreport.
-// Copyright (c) 2006-2009 The bugreport Developers.
-// See AUTHORS.txt for details.
-// Licensed under the GNU General Public License, Version 3 (GPLv3).
-// See LICENSE.txt for details.
-
+// This file is part of bugreport.
+// Copyright (c) 2006-2009 The bugreport Developers.
+// See AUTHORS.txt for details.
+// Licensed under the GNU General Public License, Version 3 (GPLv3).
+// See LICENSE.txt for details.
+
using System;
using NUnit.Framework;
-namespace bugreport
-{
- [TestFixture]
- public class AbstractValueTest
- {
- private AbstractValue pointer;
- private AbstractBuffer buffer;
-
- [Test]
- public void AddTaint()
- {
- var clean = new AbstractValue(0x31337);
- Assert.IsFalse(clean.IsTainted);
- AbstractValue tainted = clean.AddTaint();
- Assert.IsTrue(tainted.IsTainted);
- Assert.AreNotSame(clean, tainted);
+namespace bugreport
+{
+ [TestFixture]
+ public class AbstractValueTest
+ {
+ private AbstractValue pointer;
+ private AbstractBuffer buffer;
+
+ [Test]
+ public void AddTaint()
+ {
+ var clean = new AbstractValue(0x31337);
+ Assert.IsFalse(clean.IsTainted);
+ AbstractValue tainted = clean.AddTaint();
+ Assert.IsTrue(tainted.IsTainted);
+ Assert.AreNotSame(clean, tainted);
}
- [Test]
- public void AddTaintIf()
- {
- var clean = new AbstractValue(0x31337);
- Assert.IsFalse(clean.IsTainted);
- AbstractValue notTainted = clean.AddTaintIf(0 == 1);
- Assert.IsFalse(notTainted.IsTainted);
- Assert.AreSame(clean, notTainted);
-
- AbstractValue tainted = clean.AddTaintIf(1 == 1);
- Assert.IsTrue(tainted.IsTainted);
- Assert.AreNotSame(clean, tainted);
- }
-
- [Test]
- [ExpectedException(typeof (InvalidOperationException))]
- public void AddTaintOnPointer()
- {
- var buffer = new AbstractBuffer(AbstractValue.GetNewBuffer(1));
- var clean = new AbstractValue(buffer);
- clean.AddTaint();
+ [Test]
+ public void AddTaintIf()
+ {
+ var clean = new AbstractValue(0x31337);
+ Assert.IsFalse(clean.IsTainted);
+ AbstractValue notTainted = clean.AddTaintIf(0 == 1);
+ Assert.IsFalse(notTainted.IsTainted);
+ Assert.AreSame(clean, notTainted);
+
+ AbstractValue tainted = clean.AddTaintIf(1 == 1);
+ Assert.IsTrue(tainted.IsTainted);
+ Assert.AreNotSame(clean, tainted);
}
- [Test]
- public void AssignmentAtByteZero()
- {
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
- pointer = new AbstractValue(buffer);
- pointer.PointsTo[0] = new AbstractValue(0x31337);
- Assert.AreEqual(0x31337, pointer.PointsTo[0].Value);
- Assert.AreEqual("*0x00031337", pointer.ToString());
- }
-
- [Test]
- public void AssignmentAtEnd()
- {
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
- pointer = new AbstractValue(buffer);
- pointer.PointsTo[15] = new AbstractValue(0x31337);
- Assert.AreEqual(0x31337, pointer.PointsTo[15].Value);
+ [Test]
+ [ExpectedException(typeof(InvalidOperationException))]
+ public void AddTaintOnPointer()
+ {
+ var buffer = new AbstractBuffer(AbstractValue.GetNewBuffer(1));
+ var clean = new AbstractValue(buffer);
+ clean.AddTaint();
}
- [Test]
- public void CheckOOBAfterCopy()
- {
- var src = new AbstractValue(0x31337);
- src.IsOOB = false;
- var dest = new AbstractValue(0x1);
- dest.IsOOB = true;
- dest = new AbstractValue(src);
-
- Assert.IsFalse(dest.IsOOB);
- }
-
- [Test]
- [ExpectedException(typeof (ArgumentException))]
- public void EmptyBuffer()
- {
- pointer = new AbstractValue(new AbstractBuffer(new AbstractValue[] {}));
+ [Test]
+ public void AssignmentAtByteZero()
+ {
+ AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
+ pointer = new AbstractValue(buffer);
+ pointer.PointsTo[0] = new AbstractValue(0x31337);
+ Assert.AreEqual(0x31337, pointer.PointsTo[0].Value);
+ Assert.AreEqual("*0x00031337", pointer.ToString());
}
- [Test]
- public void Equals()
- {
- Assert.IsFalse(new AbstractValue().Equals(null));
+ [Test]
+ public void AssignmentAtEnd()
+ {
+ AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
+ pointer = new AbstractValue(buffer);
+ pointer.PointsTo[15] = new AbstractValue(0x31337);
+ Assert.AreEqual(0x31337, pointer.PointsTo[15].Value);
}
- [Test]
- public void Initialized()
- {
- var uninit = new AbstractValue(0xabcdef);
- Assert.IsTrue(uninit.IsInitialized);
- Assert.AreEqual(0xabcdef, uninit.Value);
- }
-
- [Test]
- public void NoPointer()
- {
- AbstractValue value = new AbstractValue(2).AddTaint();
-
- Assert.IsNull(value.PointsTo);
- StringAssert.Contains("0x00000002", value.ToString());
+ [Test]
+ public void CheckOOBAfterCopy()
+ {
+ var src = new AbstractValue(0x31337);
+ src.IsOOB = false;
+ var dest = new AbstractValue(0x1);
+ dest.IsOOB = true;
+ dest = new AbstractValue(src);
+
+ Assert.IsFalse(dest.IsOOB);
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void EmptyBuffer()
+ {
+ pointer = new AbstractValue(new AbstractBuffer(new AbstractValue[] {}));
+ }
+
+ [Test]
+ public void Equals()
+ {
+ Assert.IsFalse(new AbstractValue().Equals(null));
+ }
+
+ [Test]
+ public void Initialized()
+ {
+ var uninit = new AbstractValue(0xabcdef);
+ Assert.IsTrue(uninit.IsInitialized);
+ Assert.AreEqual(0xabcdef, uninit.Value);
+ }
+
+ [Test]
+ public void NoPointer()
+ {
+ AbstractValue value = new AbstractValue(2).AddTaint();
+
+ Assert.IsNull(value.PointsTo);
+ StringAssert.Contains("0x00000002", value.ToString());
StringAssert.Contains("t", value.ToString());
}
- [Test]
- public void NotInitialized()
- {
- var uninitializedValue = new AbstractValue();
- Assert.IsFalse(uninitializedValue.IsInitialized);
- Assert.AreEqual(AbstractValue.UNKNOWN, uninitializedValue.Value);
- Assert.AreEqual("?", uninitializedValue.ToString());
+ [Test]
+ public void NotInitialized()
+ {
+ var uninitializedValue = new AbstractValue();
+ Assert.IsFalse(uninitializedValue.IsInitialized);
+ Assert.AreEqual(AbstractValue.UNKNOWN, uninitializedValue.Value);
+ Assert.AreEqual("?", uninitializedValue.ToString());
}
- [Test]
- [ExpectedException(typeof (ArgumentNullException))]
- public void NullCopyCtor()
- {
- pointer = new AbstractValue((AbstractValue) null);
- }
-
- [Test]
- public void Pointer()
- {
- buffer = new AbstractBuffer(new[] {new AbstractValue(2)});
- pointer = new AbstractValue(buffer);
- Assert.AreEqual(2, pointer.PointsTo[0].Value);
- StringAssert.StartsWith("*0x00000002", pointer.ToString());
+ [Test]
+ [ExpectedException(typeof(ArgumentNullException))]
+ public void NullCopyCtor()
+ {
+ pointer = new AbstractValue((AbstractValue) null);
}
- [Test]
- public void PointerHashcodes()
- {
- pointer = new AbstractValue(new[] {new AbstractValue(1)});
- var pointer2 = new AbstractValue(new[] {new AbstractValue(2)});
-
- Assert.AreNotEqual(pointer.GetHashCode(), pointer2.GetHashCode());
- }
-
- [Test]
- public void PointerPointer()
- {
- buffer = new AbstractBuffer(new[] {new AbstractValue(2)});
- pointer = new AbstractValue(buffer);
- var pointerPointer = new AbstractValue(new[] {pointer});
- Assert.AreEqual(2, pointerPointer.PointsTo[0].PointsTo[0].Value);
- StringAssert.StartsWith("**0x00000002", pointerPointer.ToString());
- }
-
- [Test]
- public void PointerPointerPointer()
- {
- buffer = new AbstractBuffer(new[] {new AbstractValue(2)});
- pointer = new AbstractValue(buffer);
- var pointerPointer = new AbstractValue(new[] {pointer});
- var pointerPointerPointer = new AbstractValue(new[] {pointerPointer});
- Assert.AreEqual(2, pointerPointerPointer.PointsTo[0].PointsTo[0].PointsTo[0].Value);
-
- StringAssert.StartsWith("***0x00000002", pointerPointerPointer.ToString());
- }
-
- [Test]
- public void PreserveIsOOBAfterCopy()
- {
- var src = new AbstractValue(0x31337);
- var dest = new AbstractValue(0x1);
- src.IsOOB = true;
- dest = new AbstractValue(src);
-
- Assert.IsTrue(dest.IsOOB);
- }
-
- [Test]
- [ExpectedException(typeof (ArgumentOutOfRangeException))]
- public void RequestedBufferTooLarge()
- {
- AbstractValue.GetNewBuffer(AbstractValue.MAX_BUFFER_SIZE + 1);
+ [Test]
+ public void Pointer()
+ {
+ buffer = new AbstractBuffer(new[] {new AbstractValue(2)});
+ pointer = new AbstractValue(buffer);
+ Assert.AreEqual(2, pointer.PointsTo[0].Value);
+ StringAssert.StartsWith("*0x00000002", pointer.ToString());
}
- [Test]
- public void TruncateValue()
- {
- var dwordValue = new AbstractValue(0xdeadbeef);
- AbstractValue byteValue = dwordValue.TruncateValueToByte();
- Assert.AreEqual(0xef, byteValue.Value);
+ [Test]
+ public void PointerHashcodes()
+ {
+ pointer = new AbstractValue(new[] {new AbstractValue(1)});
+ var pointer2 = new AbstractValue(new[] {new AbstractValue(2)});
+
+ Assert.AreNotEqual(pointer.GetHashCode(), pointer2.GetHashCode());
}
- [Test]
- [ExpectedException(typeof (ArgumentException))]
- public void ZeroSizeBuffer()
- {
- pointer = new AbstractValue(new AbstractValue[] {});
- }
- }
+ [Test]
+ public void PointerPointer()
+ {
+ buffer = new AbstractBuffer(new[] {new AbstractValue(2)});
+ pointer = new AbstractValue(buffer);
+ var pointerPointer = new AbstractValue(new[] {pointer});
+ Assert.AreEqual(2, pointerPointer.PointsTo[0].PointsTo[0].Value);
+ StringAssert.StartsWith("**0x00000002", pointerPointer.ToString());
+ }
+
+ [Test]
+ public void PointerPointerPointer()
+ {
+ buffer = new AbstractBuffer(new[] {new AbstractValue(2)});
+ pointer = new AbstractValue(buffer);
+ var pointerPointer = new AbstractValue(new[] {pointer});
+ var pointerPointerPointer = new AbstractValue(new[] {pointerPointer});
+ Assert.AreEqual(2, pointerPointerPointer.PointsTo[0].PointsTo[0].PointsTo[0].Value);
+
+ StringAssert.StartsWith("***0x00000002", pointerPointerPointer.ToString());
+ }
+
+ [Test]
+ public void PreserveIsOOBAfterCopy()
+ {
+ var src = new AbstractValue(0x31337);
+ var dest = new AbstractValue(0x1);
+ src.IsOOB = true;
+ dest = new AbstractValue(src);
+
+ Assert.IsTrue(dest.IsOOB);
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentOutOfRangeException))]
+ public void RequestedBufferTooLarge()
+ {
+ AbstractValue.GetNewBuffer(AbstractValue.MAX_BUFFER_SIZE + 1);
+ }
+
+ [Test]
+ public void TruncateValue()
+ {
+ var dwordValue = new AbstractValue(0xdeadbeef);
+ AbstractValue byteValue = dwordValue.TruncateValueToByte();
+ Assert.AreEqual(0xef, byteValue.Value);
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void ZeroSizeBuffer()
+ {
+ pointer = new AbstractValue(new AbstractValue[] {});
+ }
+ }
}
\ No newline at end of file
Modified: AnalysisEngine.csproj
===================================================================
--- AnalysisEngine.csproj 2009-01-29 05:41:37 UTC (rev 164)
+++ AnalysisEngine.csproj 2009-01-29 21:45:15 UTC (rev 165)
@@ -60,8 +60,6 @@
<Compile Include="AbstractValueTest.cs" />
<Compile Include="Analyzer.cs" />
<Compile Include="AnalyzerTest.cs" />
- <Compile Include="ArmEmulator.cs" />
- <Compile Include="ArmEmulatorTest.cs" />
<Compile Include="BitMathTest.cs" />
<Compile Include="Contract.cs" />
<Compile Include="CoverageExcludeAttribute.cs" />
@@ -70,6 +68,7 @@
<Compile Include="ElfFileParserTest.cs" />
<Compile Include="GLibcStartMainContract.cs" />
<Compile Include="GLibcStartMainContractTest.cs" />
+ <Compile Include="InvalidOpcodeException.cs" />
<Compile Include="MachineStateTest.cs" />
<Compile Include="MallocContract.cs" />
<Compile Include="ModRMTest.cs" />
Modified: Analyzer.cs
===================================================================
--- Analyzer.cs 2009-01-29 05:41:37 UTC (rev 164)
+++ Analyzer.cs 2009-01-29 21:45:15 UTC (rev 165)
@@ -1,174 +1,176 @@
-// This file is part of bugreport.
-// Copyright (c) 2006-2009 The bugreport Developers.
-// See AUTHORS.txt for details.
-// Licensed under the GNU General Public License, Version 3 (GPLv3).
-// See LICENSE.txt for details.
-
+// This file is part of bugreport.
+// Copyright (c) 2006-2009 The bugreport Developers.
+// See AUTHORS.txt for details.
+// Licensed under the GNU General Public License, Version 3 (GPLv3).
+// See LICENSE.txt for details.
+
using System;
using System.Collections.ObjectModel;
-namespace bugreport
-{
- public class EmulationEventArgs : EventArgs
- {
+namespace bugreport
+{
+ public class EmulationEventArgs : EventArgs
+ {
private readonly ReadOnlyCollection<Byte> code;
- private readonly MachineState state;
-
- public EmulationEventArgs(MachineState state, ReadOnlyCollection<Byte> code)
- {
- this.state = state;
- this.code = code;
- }
-
- public MachineState MachineState
- {
- get { return state; }
- }
-
- public ReadOnlyCollection<Byte> Code
- {
- get { return code; }
- }
- }
-
- public class ReportEventArgs : EventArgs
- {
- private readonly ReportItem reportItem;
-
- public ReportEventArgs(ReportItem reportItem)
- {
- this.reportItem = reportItem;
- }
-
- public ReportItem ReportItem
- {
- get { return reportItem; }
- }
- }
-
- public class ReportCollection : Collection<ReportItem>
- {
- public EventHandler<ReportEventArgs> OnReport;
-
- protected override void InsertItem(int index, ReportItem item)
- {
- base.InsertItem(index, item);
-
- if (null != OnReport)
- {
- OnReport(this, new ReportEventArgs(item));
- }
- }
- }
-
- public class Analyzer
- {
+ private readonly MachineState state;
+
+ public EmulationEventArgs(MachineState state, ReadOnlyCollection<Byte> code)
+ {
+ this.state = state;
+ this.code = code;
+ }
+
+ public MachineState MachineState
+ {
+ get { return state; }
+ }
+
+ public ReadOnlyCollection<Byte> Code
+ {
+ get { return code; }
+ }
+ }
+
+ public class ReportEventArgs : EventArgs
+ {
+ private readonly ReportItem reportItem;
+
+ public ReportEventArgs(ReportItem reportItem)
+ {
+ this.reportItem = reportItem;
+ }
+
+ public ReportItem ReportItem
+ {
+ get { return reportItem; }
+ }
+ }
+
+ public class ReportCollection : Collection<ReportItem>
+ {
+ public EventHandler<ReportEventArgs> OnReport;
+
+ protected override void InsertItem(int index, ReportItem item)
+ {
+ base.InsertItem(index, item);
+
+ if (null != OnReport)
+ {
+ OnReport(this, new ReportEventArgs(item));
+ }
+ }
+ }
+
+ public class Analyzer
+ {
+ public EventHandler<EmulationEventArgs> OnEmulationComplete;
private readonly Opcode opcode = new X86Opcode();
private readonly IParsable parser;
- public EventHandler<EmulationEventArgs> OnEmulationComplete;
-
- protected ReportCollection reportItems;
-
- public Analyzer(IParsable parser)
- {
- if (null == parser)
- {
- throw new ArgumentNullException("parser");
- }
-
- this.parser = parser;
-
- reportItems = new ReportCollection();
- }
-
- public ReadOnlyCollection<ReportItem> ActualReportItems
- {
- get { return new ReadOnlyCollection<ReportItem>(reportItems); }
- }
-
- public ReadOnlyCollection<ReportItem> ExpectedReportItems
- {
- get { return parser.ExpectedReportItems; }
- }
-
- public EventHandler<ReportEventArgs> OnReport
- {
- get { return reportItems.OnReport; }
- set { reportItems.OnReport = value; }
- }
-
-
- private static RegisterCollection getRegistersForLinuxStart()
- {
- var linuxMainDefaultValues = new RegisterCollection();
-
- AbstractValue arg0 = new AbstractValue(1).AddTaint();
-
- var argvBuffer = new[] {arg0};
- var argvPointer = new AbstractValue(argvBuffer);
- var argvPointerBuffer = new[] {argvPointer};
- var argvPointerPointer = new AbstractValue(argvPointerBuffer);
- AbstractValue[] stackBuffer = AbstractValue.GetNewBuffer(0x200);
-
- var buffer = new AbstractBuffer(stackBuffer);
- AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(0x100));
-
- // linux ABI dictates
- modifiedBuffer[5] = argvPointerPointer;
-
- // gcc generates code that accesses this at some optimization levels
- modifiedBuffer[0xfc] = new AbstractValue(1);
-
- var stackPointer = new AbstractValue(modifiedBuffer);
- linuxMainDefaultValues[RegisterName.ESP] = stackPointer;
-
- return linuxMainDefaultValues;
- }
-
-
- protected virtual MachineState runCode(MachineState _machineState, Byte[] code)
- {
- return X86Emulator.Run(reportItems, _machineState, code);
- }
-
- public void Run()
- {
- var machineState = new MachineState(getRegistersForLinuxStart());
- machineState.InstructionPointer = parser.EntryPointAddress;
- Byte[] instructions = parser.GetBytes();
- UInt32 index = machineState.InstructionPointer - parser.BaseAddress;
-
- while (index < instructions.Length)
- {
- MachineState savedState = machineState;
- Byte[] instruction = extractInstruction(instructions, index);
-
- machineState = runCode(machineState, instruction);
- if (null != OnEmulationComplete)
- {
+ private ReportCollection reportItems;
+
+ public Analyzer(IParsable parser)
+ {
+ if (null == parser)
+ {
+ throw new ArgumentNullException("parser");
+ }
+
+ this.parser = parser;
+
+ reportItems = new ReportCollection();
+ }
+
+ public ReadOnlyCollection<ReportItem> ActualReportItems
+ {
+ get { return new ReadOnlyCollection<ReportItem>(reportItems); }
+ }
+
+ public ReadOnlyCollection<ReportItem> ExpectedReportItems
+ {
+ get { return parser.ExpectedReportItems; }
+ }
+
+ public EventHandler<ReportEventArgs> OnReport
+ {
+ get { return reportItems.OnReport; }
+ set { reportItems.OnReport = value; }
+ }
+
+ protected ReportCollection ReportItems
+ {
+ get { return reportItems; }
+ }
+
+ public void Run()
+ {
+ var machineState = new MachineState(getRegistersForLinuxStart());
+ machineState.InstructionPointer = parser.EntryPointAddress;
+ Byte[] instructions = parser.GetBytes();
+ UInt32 index = machineState.InstructionPointer - parser.BaseAddress;
+
+ while (index < instructions.Length)
+ {
+ MachineState savedState = machineState;
+ Byte[] instruction = extractInstruction(instructions, index);
+
+ machineState = runCode(machineState, instruction);
+ if (null != OnEmulationComplete)
+ {
OnEmulationComplete(
- this, new EmulationEventArgs(savedState, new ReadOnlyCollection<Byte>(instruction)));
- }
-
- index = machineState.InstructionPointer - parser.BaseAddress;
-
- if (opcode.TerminatesFunction(instruction))
- {
- break;
- }
- }
- }
-
- private Byte[] extractInstruction(Byte[] instructions, UInt32 index)
- {
- Byte instructionLength = opcode.GetInstructionLength(instructions, index);
- var instruction = new Byte[instructionLength];
- for (UInt32 count = index; count < index + instructionLength; count++)
- {
- instruction[count - index] = instructions[count];
- }
-
- return instruction;
- }
- }
+ this, new EmulationEventArgs(savedState, new ReadOnlyCollection<Byte>(instruction)));
+ }
+
+ index = machineState.InstructionPointer - parser.BaseAddress;
+
+ if (opcode.TerminatesFunction(instruction))
+ {
+ break;
+ }
+ }
+ }
+
+ protected virtual MachineState runCode(MachineState _machineState, Byte[] code)
+ {
+ return X86Emulator.Run(reportItems, _machineState, code);
+ }
+
+ private static RegisterCollection getRegistersForLinuxStart()
+ {
+ var linuxMainDefaultValues = new RegisterCollection();
+
+ AbstractValue arg0 = new AbstractValue(1).AddTaint();
+
+ var argvBuffer = new[] {arg0};
+ var argvPointer = new AbstractValue(argvBuffer);
+ var argvPointerBuffer = new[] {argvPointer};
+ var argvPointerPointer = new AbstractValue(argvPointerBuffer);
+ AbstractValue[] stackBuffer = AbstractValue.GetNewBuffer(0x200);
+
+ var buffer = new AbstractBuffer(stackBuffer);
+ AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(0x100));
+
+ // linux ABI dictates
+ modifiedBuffer[5] = argvPointerPointer;
+
+ // gcc generates code that accesses this at some optimization levels
+ modifiedBuffer[0xfc] = new AbstractValue(1);
+
+ var stackPointer = new AbstractValue(modifiedBuffer);
+ linuxMainDefaultValues[RegisterName.ESP] = stackPointer;
+
+ return linuxMainDefaultValues;
+ }
+
+ private Byte[] extractInstruction(Byte[] instructions, UInt32 index)
+ {
+ Byte instructionLength = opcode.GetInstructionLength(instructions, index);
+ var instruction = new Byte[instructionLengt...
[truncated message content] |
|
From: <mat...@us...> - 2009-01-29 05:42:22
|
Revision: 164
http://bugreport.svn.sourceforge.net/bugreport/?rev=164&view=rev
Author: matt_hargett
Date: 2009-01-29 05:41:37 +0000 (Thu, 29 Jan 2009)
Log Message:
-----------
Matt - ran ReSharper 4.1 Code Cleanup.
Modified Paths:
--------------
AbstractBuffer.cs
AbstractBufferTest.cs
AbstractValue.cs
AbstractValueTest.cs
Analyzer.cs
AnalyzerTest.cs
ArmEmulator.cs
ArmEmulatorTest.cs
AssemblyInfo.cs
BitMath.cs
BitMathTest.cs
Contract.cs
CoverageExcludeAttribute.cs
DebuggerCommandTest.cs
DebuggerView.cs
DumpFileParser.cs
DumpFileParserTest.cs
ElfFileParser.cs
ElfFileParserTest.cs
GLibcStartMainContract.cs
GLibcStartMainContractTest.cs
MachineState.cs
MachineStateTest.cs
Main.cs
MainTest.cs
MallocContract.cs
ModRM.cs
ModRMTest.cs
Opcode.cs
OpcodeFormatter.cs
OpcodeFormatterTest.cs
Options.cs
OptionsTest.cs
RegisterCollection.cs
RegisterCollectionTest.cs
ReportItem.cs
ReportItemTest.cs
SIB.cs
SIBTests.cs
X86Emulator.cs
X86EmulatorTest.cs
X86Opcode.cs
X86OpcodeTest.cs
Modified: AbstractBuffer.cs
===================================================================
--- AbstractBuffer.cs 2009-01-29 05:14:45 UTC (rev 163)
+++ AbstractBuffer.cs 2009-01-29 05:41:37 UTC (rev 164)
@@ -4,15 +4,15 @@
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
-using System;
-
+using System;
+
namespace bugreport
{
public class AbstractBuffer
{
- private readonly Int32 allocatedLength;
+ private readonly Int32 allocatedLength;
+ private UInt32 baseIndex;
private AbstractValue[] storage;
- private UInt32 baseIndex;
public AbstractBuffer(AbstractValue[] _buffer)
{
@@ -35,7 +35,7 @@
// We check this.storage.Length as well so that we aren't calling Extend() when we dont need to.
if (IsIndexPastBounds(index))
{
- extend(baseIndex + (UInt32)index);
+ extend(baseIndex + (UInt32) index);
return storage[baseIndex + index];
}
@@ -51,7 +51,7 @@
if (IsIndexPastBounds(index))
{
- extend(baseIndex + (UInt32)index);
+ extend(baseIndex + (UInt32) index);
storage[baseIndex + index] = value;
}
else
@@ -81,42 +81,46 @@
{
case OperatorEffect.Assignment:
{
- AbstractBuffer result = new AbstractBuffer(lhs);
-
+ var result = new AbstractBuffer(lhs);
+
return result;
}
case OperatorEffect.Add:
{
- AbstractBuffer result = new AbstractBuffer(lhs);
+ var result = new AbstractBuffer(lhs);
result.baseIndex += _rhs.Value;
-
+
return result;
}
-
+
case OperatorEffect.Sub:
{
- AbstractBuffer result = new AbstractBuffer(lhs);
-
+ var result = new AbstractBuffer(lhs);
+
if (result.baseIndex < _rhs.Value)
{
- throw new ArgumentOutOfRangeException(String.Format("Attempting to set a negative baseindex, baseindex: {0:x4}, _subValue {1:x4}", result.baseIndex, _rhs.Value));
+ throw new ArgumentOutOfRangeException(
+ String.Format(
+ "Attempting to set a negative baseindex, baseindex: {0:x4}, _subValue {1:x4}",
+ result.baseIndex, _rhs.Value));
}
-
+
result.baseIndex -= _rhs.Value;
return result;
}
-
+
case OperatorEffect.And:
{
- AbstractBuffer result = new AbstractBuffer(lhs);
-
+ var result = new AbstractBuffer(lhs);
+
result.baseIndex &= _rhs.Value;
return result;
}
-
+
default:
- throw new ArgumentException(String.Format("Unsupported OperatorEffect: {0}", _operatorEffect), "_operatorEffect");
+ throw new ArgumentException(
+ String.Format("Unsupported OperatorEffect: {0}", _operatorEffect), "_operatorEffect");
}
}
@@ -131,7 +135,7 @@
_newLength = _newLength + 1;
if (_newLength >= Length)
{
- AbstractValue[] _copyTo = new AbstractValue[_newLength];
+ var _copyTo = new AbstractValue[_newLength];
Int32 i;
for (i = 0; i < storage.Length; i++)
@@ -151,4 +155,4 @@
return;
}
}
-}
+}
\ No newline at end of file
Modified: AbstractBufferTest.cs
===================================================================
--- AbstractBufferTest.cs 2009-01-29 05:14:45 UTC (rev 163)
+++ AbstractBufferTest.cs 2009-01-29 05:41:37 UTC (rev 164)
@@ -4,64 +4,74 @@
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
-using System;
-using NUnit.Framework;
-
+using System;
+using NUnit.Framework;
+
namespace bugreport
{
[TestFixture]
public class AbstractBufferTest
- {
+ {
[Test]
- public void PointerAssignment()
- {
- AbstractValue[] values = AbstractValue.GetNewBuffer(4);
- AbstractBuffer buffer = new AbstractBuffer(values);
- AbstractBuffer assignedBuffer = buffer.DoOperation(OperatorEffect.Assignment, null);
- Assert.AreNotSame(buffer, assignedBuffer);
- }
-
- [Test]
public void Copy()
{
AbstractValue[] values = AbstractValue.GetNewBuffer(4);
- AbstractBuffer buffer = new AbstractBuffer(values);
- AbstractBuffer newBuffer = new AbstractBuffer(buffer);
+ var buffer = new AbstractBuffer(values);
+ var newBuffer = new AbstractBuffer(buffer);
Assert.AreNotSame(newBuffer, buffer);
- for (Int32 index=0; index < newBuffer.Length; index++)
+ for (Int32 index = 0; index < newBuffer.Length; index++)
{
Assert.AreSame(newBuffer[index], buffer[index]);
}
- }
-
+ }
+
[Test]
- public void PointerAdd()
+ [ExpectedException(typeof (ArgumentOutOfRangeException))]
+ public void InvalidPointerAnd()
{
- AbstractValue one = new AbstractValue(0x1);
- AbstractValue two = new AbstractValue(0x2);
- AbstractValue three = new AbstractValue(0x3);
- AbstractValue four = new AbstractValue(0x4);
- AbstractValue[] values = AbstractValue.GetNewBuffer(4);
+ var one = new AbstractValue(0x1);
+ var buffer = new AbstractBuffer(new[] {one});
+ AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Sub, new AbstractValue(3));
+ modifiedBuffer.DoOperation(OperatorEffect.And, new AbstractValue(0xf));
+ }
+
+ [Test]
+ public void OverflowDoesntLoseIncrement()
+ {
+ AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
+ var pointer = new AbstractBuffer(buffer);
+ var value = new AbstractValue(0x41);
+ value = value.AddTaint();
- values[0] = one;
- values[1] = two;
- values[2] = three;
- values[3] = four;
+ pointer[0] = value;
- AbstractBuffer buffer = new AbstractBuffer(values);
- Assert.AreEqual(one, buffer[0]);
- AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(2));
- Assert.AreEqual(three, modifiedBuffer[0]);
+ pointer = pointer.DoOperation(OperatorEffect.Add, new AbstractValue(1));
+
+ pointer[16] = value;
+
+ pointer = pointer.DoOperation(OperatorEffect.Sub, new AbstractValue(1));
+
+ Assert.AreEqual(0x41, pointer[0].Value);
+ Assert.IsTrue(value.IsTainted);
+ Assert.AreEqual(0x41, pointer[17].Value);
+ Assert.IsTrue(pointer[17].IsTainted);
}
[Test]
- public void PointerSub()
+ public void OverflowZeroSizeBuffer()
{
- AbstractValue one = new AbstractValue(0x1);
- AbstractValue two = new AbstractValue(0x2);
- AbstractValue three = new AbstractValue(0x3);
- AbstractValue four = new AbstractValue(0x4);
+ var f = new AbstractBuffer(new AbstractValue[] {});
+ Assert.IsFalse(f[0].IsInitialized);
+ }
+
+ [Test]
+ public void PointerAdd()
+ {
+ var one = new AbstractValue(0x1);
+ var two = new AbstractValue(0x2);
+ var three = new AbstractValue(0x3);
+ var four = new AbstractValue(0x4);
AbstractValue[] values = AbstractValue.GetNewBuffer(4);
values[0] = one;
@@ -69,29 +79,19 @@
values[2] = three;
values[3] = four;
- AbstractBuffer buffer = new AbstractBuffer(values);
+ var buffer = new AbstractBuffer(values);
Assert.AreEqual(one, buffer[0]);
AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(2));
Assert.AreEqual(three, modifiedBuffer[0]);
-
- AbstractBuffer subbedBuffer = modifiedBuffer.DoOperation(OperatorEffect.Sub, new AbstractValue(2));
- Assert.AreEqual(one, subbedBuffer[0]);
}
[Test]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- public void PointerSubUnderflow()
- {
- new AbstractBuffer(new AbstractValue[] {}).DoOperation(OperatorEffect.Sub, new AbstractValue(1));
- }
-
- [Test]
public void PointerAnd()
{
- AbstractValue one = new AbstractValue(0x1);
- AbstractValue two = new AbstractValue(0x2);
- AbstractValue three = new AbstractValue(0x3);
- AbstractValue four = new AbstractValue(0x4);
+ var one = new AbstractValue(0x1);
+ var two = new AbstractValue(0x2);
+ var three = new AbstractValue(0x3);
+ var four = new AbstractValue(0x4);
AbstractValue[] avBuffer = AbstractValue.GetNewBuffer(4);
avBuffer[0] = one;
@@ -99,36 +99,28 @@
avBuffer[2] = three;
avBuffer[3] = four;
- AbstractBuffer buffer = new AbstractBuffer(avBuffer);
+ var buffer = new AbstractBuffer(avBuffer);
Assert.AreEqual(one, buffer[0]);
AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(3));
Assert.AreEqual(four, modifiedBuffer[0]);
AbstractBuffer andedBuffer = modifiedBuffer.DoOperation(OperatorEffect.And, new AbstractValue(0xfffffff0));
Assert.AreEqual(one, andedBuffer[0]);
- }
-
+ }
+
[Test]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- public void InvalidPointerAnd()
+ public void PointerAssignment()
{
- AbstractValue one = new AbstractValue(0x1);
- AbstractBuffer buffer = new AbstractBuffer(new AbstractValue[] {one});
- AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Sub, new AbstractValue(3));
- modifiedBuffer.DoOperation(OperatorEffect.And, new AbstractValue(0xf));
+ AbstractValue[] values = AbstractValue.GetNewBuffer(4);
+ var buffer = new AbstractBuffer(values);
+ AbstractBuffer assignedBuffer = buffer.DoOperation(OperatorEffect.Assignment, null);
+ Assert.AreNotSame(buffer, assignedBuffer);
}
[Test]
- [ExpectedException(typeof(ArgumentException))]
- public void PointerUnknownOperation()
- {
- new AbstractBuffer(new AbstractValue[] {}).DoOperation(OperatorEffect.Unknown, null);
- }
-
- [Test]
public void PointerOverflowByOne()
{
AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
- AbstractBuffer pointer = new AbstractBuffer(buffer);
+ var pointer = new AbstractBuffer(buffer);
AbstractValue value = pointer[16];
Assert.IsTrue(value.IsOOB);
@@ -139,14 +131,14 @@
[Test]
public void PointerOverflowStillRetainsOldValues()
{
- AbstractValue test1 = new AbstractValue(0x41);
- AbstractValue test2 = new AbstractValue(0x42);
+ var test1 = new AbstractValue(0x41);
+ var test2 = new AbstractValue(0x42);
AbstractValue[] buffer = AbstractValue.GetNewBuffer(2);
buffer[0] = test1;
buffer[1] = test2;
- AbstractBuffer pointer = new AbstractBuffer(buffer);
+ var pointer = new AbstractBuffer(buffer);
// Accessing pointer[2] will cause the AbstractBuffer to extend..
Assert.IsTrue(pointer[2].IsOOB, " value is not out of bounds");
@@ -165,7 +157,7 @@
public void PointerOverflowTwiceStillRetainsOriginalValues()
{
AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
- AbstractBuffer pointer = new AbstractBuffer(buffer);
+ var pointer = new AbstractBuffer(buffer);
//Access beyond buffer bounds forcing buffer to expand
Assert.IsTrue(pointer[17].IsOOB);
@@ -182,35 +174,43 @@
// check that value set outside of bounds is still the same as well
Assert.IsTrue(pointer[17].IsOOB);
Assert.AreEqual(0x41414141, pointer[17].Value);
- }
-
+ }
+
[Test]
- public void OverflowDoesntLoseIncrement()
+ public void PointerSub()
{
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
- AbstractBuffer pointer = new AbstractBuffer(buffer);
- AbstractValue value = new AbstractValue(0x41);
- value = value.AddTaint();
+ var one = new AbstractValue(0x1);
+ var two = new AbstractValue(0x2);
+ var three = new AbstractValue(0x3);
+ var four = new AbstractValue(0x4);
+ AbstractValue[] values = AbstractValue.GetNewBuffer(4);
- pointer[0] = value;
+ values[0] = one;
+ values[1] = two;
+ values[2] = three;
+ values[3] = four;
- pointer = pointer.DoOperation(OperatorEffect.Add, new AbstractValue(1));
+ var buffer = new AbstractBuffer(values);
+ Assert.AreEqual(one, buffer[0]);
+ AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(2));
+ Assert.AreEqual(three, modifiedBuffer[0]);
- pointer[16] = value;
-
- pointer = pointer.DoOperation(OperatorEffect.Sub, new AbstractValue(1));
-
- Assert.AreEqual(0x41, pointer[0].Value);
- Assert.IsTrue(value.IsTainted);
- Assert.AreEqual(0x41, pointer[17].Value);
- Assert.IsTrue(pointer[17].IsTainted);
+ AbstractBuffer subbedBuffer = modifiedBuffer.DoOperation(OperatorEffect.Sub, new AbstractValue(2));
+ Assert.AreEqual(one, subbedBuffer[0]);
}
[Test]
- public void OverflowZeroSizeBuffer()
+ [ExpectedException(typeof (ArgumentOutOfRangeException))]
+ public void PointerSubUnderflow()
{
- AbstractBuffer f = new AbstractBuffer(new AbstractValue[] {});
- Assert.IsFalse(f[0].IsInitialized);
- }
+ new AbstractBuffer(new AbstractValue[] {}).DoOperation(OperatorEffect.Sub, new AbstractValue(1));
+ }
+
+ [Test]
+ [ExpectedException(typeof (ArgumentException))]
+ public void PointerUnknownOperation()
+ {
+ new AbstractBuffer(new AbstractValue[] {}).DoOperation(OperatorEffect.Unknown, null);
+ }
}
-}
+}
\ No newline at end of file
Modified: AbstractValue.cs
===================================================================
--- AbstractValue.cs 2009-01-29 05:14:45 UTC (rev 163)
+++ AbstractValue.cs 2009-01-29 05:41:37 UTC (rev 164)
@@ -4,22 +4,20 @@
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
-using System;
-using System.Text;
-
+using System;
+using System.Text;
+
namespace bugreport
{
public class AbstractValue
{
- AbstractBuffer pointsTo;
- UInt32 storage;
- Boolean tainted;
- Boolean isOOB;
+ public const UInt32 MAX_BUFFER_SIZE = 25600000;
+ public const UInt32 UNKNOWN = 0xb4dc0d3d;
+ private readonly AbstractBuffer pointsTo;
+ private readonly UInt32 storage;
+ private Boolean tainted;
- public const UInt32 UNKNOWN = 0xb4dc0d3d;
- public const UInt32 MAX_BUFFER_SIZE = 25600000;
-
- public AbstractValue()
+ public AbstractValue()
{
storage = UNKNOWN;
}
@@ -30,7 +28,7 @@
{
throw new ArgumentException("Empty buffer is not allowed", "_willPointTo");
}
-
+
storage = 0xdeadbeef;
pointsTo = new AbstractBuffer(_willPointTo);
}
@@ -41,7 +39,7 @@
{
throw new ArgumentException("Empty buffer is not allowed", "_willPointTo");
}
-
+
storage = 0xdeadbeef;
pointsTo = new AbstractBuffer(_willPointTo);
}
@@ -55,7 +53,7 @@
storage = _copyMe.Value;
tainted = _copyMe.IsTainted;
- isOOB = _copyMe.IsOOB;
+ IsOOB = _copyMe.IsOOB;
if (_copyMe.PointsTo != null)
{
@@ -68,29 +66,58 @@
storage = _value;
}
+ public AbstractBuffer PointsTo
+ {
+ get { return pointsTo; }
+ }
+
+ public Boolean IsTainted
+ {
+ get { return tainted; }
+
+ private set { tainted = value; }
+ }
+
+ public Boolean IsOOB { get; set; }
+
+ public Boolean IsInitialized
+ {
+ get { return storage != UNKNOWN; }
+ }
+
+ public UInt32 Value
+ {
+ get { return storage; }
+ }
+
+ public Boolean IsPointer
+ {
+ get { return pointsTo != null; }
+ }
+
public override Boolean Equals(object obj)
{
- AbstractValue other = obj as AbstractValue;
+ var other = obj as AbstractValue;
if (null == other)
{
return false;
}
- return this.Value == other.Value &&
- this.IsOOB == other.IsOOB &&
- this.IsTainted == other.IsTainted &&
- this.PointsTo == other.PointsTo;
+ return Value == other.Value &&
+ IsOOB == other.IsOOB &&
+ IsTainted == other.IsTainted &&
+ PointsTo == other.PointsTo;
}
public override Int32 GetHashCode()
{
- Int32 hashCode = this.Value.GetHashCode() ^ this.IsOOB.GetHashCode() ^
- this.IsTainted.GetHashCode();
+ Int32 hashCode = Value.GetHashCode() ^ IsOOB.GetHashCode() ^
+ IsTainted.GetHashCode();
- if (this.PointsTo != null)
+ if (PointsTo != null)
{
- hashCode ^= this.PointsTo.GetHashCode();
+ hashCode ^= PointsTo.GetHashCode();
}
return hashCode;
@@ -100,35 +127,36 @@
{
if (size > MAX_BUFFER_SIZE)
{
- throw new ArgumentOutOfRangeException("size", "Size specified larger than maximum allowed: " + MAX_BUFFER_SIZE);
+ throw new ArgumentOutOfRangeException(
+ "size", "Size specified larger than maximum allowed: " + MAX_BUFFER_SIZE);
}
-
- AbstractValue[] buffer = new AbstractValue[size];
+
+ var buffer = new AbstractValue[size];
for (UInt32 i = 0; i < size; i++)
{
buffer[i] = new AbstractValue();
}
-
+
return buffer;
}
public AbstractValue TruncateValueToByte()
{
- UInt32 byteValue = this.Value & 0xff;
- AbstractValue truncatedValue = new AbstractValue(byteValue);
- truncatedValue.IsTainted = this.IsTainted;
+ UInt32 byteValue = Value & 0xff;
+ var truncatedValue = new AbstractValue(byteValue);
+ truncatedValue.IsTainted = IsTainted;
return truncatedValue;
}
public AbstractValue AddTaint()
{
- if (this.PointsTo != null)
+ if (PointsTo != null)
{
throw new InvalidOperationException("Cannot AddTaint to a pointer");
}
- AbstractValue taintedValue = new AbstractValue(this);
+ var taintedValue = new AbstractValue(this);
taintedValue.IsTainted = true;
return taintedValue;
}
@@ -143,39 +171,6 @@
return this;
}
- public AbstractBuffer PointsTo
- {
- get { return pointsTo; }
- }
-
- public Boolean IsTainted
- {
- get { return tainted; }
-
- private set { tainted = value; }
- }
-
- public Boolean IsOOB
- {
- get { return isOOB; }
- set { isOOB = value; }
- }
-
- public Boolean IsInitialized
- {
- get { return storage != UNKNOWN; }
- }
-
- public UInt32 Value
- {
- get { return storage; }
- }
-
- public Boolean IsPointer
- {
- get { return pointsTo != null; }
- }
-
public override String ToString()
{
String result = String.Empty;
@@ -183,13 +178,13 @@
if (tainted)
result += "t";
- UInt32 valueToPrint = this.Value;
+ UInt32 valueToPrint = Value;
if (pointsTo != null)
{
AbstractValue pointer = pointsTo[0];
- StringBuilder newResult = new StringBuilder(result);
+ var newResult = new StringBuilder(result);
const Byte maximumPointerDepth = 100;
Int32 count = maximumPointerDepth;
@@ -222,4 +217,4 @@
return result;
}
}
-}
+}
\ No newline at end of file
Modified: AbstractValueTest.cs
===================================================================
--- AbstractValueTest.cs 2009-01-29 05:14:45 UTC (rev 163)
+++ AbstractValueTest.cs 2009-01-29 05:41:37 UTC (rev 164)
@@ -4,53 +4,54 @@
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
-using NUnit.Framework;
-using System;
-
+using System;
+using NUnit.Framework;
+
namespace bugreport
{
[TestFixture]
public class AbstractValueTest
{
- AbstractValue pointer;
- AbstractBuffer buffer;
+ private AbstractValue pointer;
+ private AbstractBuffer buffer;
[Test]
- public void NotInitialized()
+ public void AddTaint()
{
- AbstractValue uninitializedValue = new AbstractValue();
- Assert.IsFalse(uninitializedValue.IsInitialized);
- Assert.AreEqual(AbstractValue.UNKNOWN, uninitializedValue.Value);
- Assert.AreEqual("?", uninitializedValue.ToString());
- }
-
+ var clean = new AbstractValue(0x31337);
+ Assert.IsFalse(clean.IsTainted);
+ AbstractValue tainted = clean.AddTaint();
+ Assert.IsTrue(tainted.IsTainted);
+ Assert.AreNotSame(clean, tainted);
+ }
+
[Test]
- public void Initialized()
+ public void AddTaintIf()
{
- AbstractValue uninit = new AbstractValue(0xabcdef);
- Assert.IsTrue(uninit.IsInitialized);
- Assert.AreEqual(0xabcdef, uninit.Value);
- }
+ var clean = new AbstractValue(0x31337);
+ Assert.IsFalse(clean.IsTainted);
+ AbstractValue notTainted = clean.AddTaintIf(0 == 1);
+ Assert.IsFalse(notTainted.IsTainted);
+ Assert.AreSame(clean, notTainted);
- [Test]
- public void Equals()
- {
- Assert.IsFalse(new AbstractValue().Equals(null));
+ AbstractValue tainted = clean.AddTaintIf(1 == 1);
+ Assert.IsTrue(tainted.IsTainted);
+ Assert.AreNotSame(clean, tainted);
}
[Test]
- public void PointerHashcodes()
+ [ExpectedException(typeof (InvalidOperationException))]
+ public void AddTaintOnPointer()
{
- pointer = new AbstractValue(new[] {new AbstractValue(1)});
- var pointer2 = new AbstractValue(new[] {new AbstractValue(2)});
-
- Assert.AreNotEqual(pointer.GetHashCode(), pointer2.GetHashCode());
- }
-
+ var buffer = new AbstractBuffer(AbstractValue.GetNewBuffer(1));
+ var clean = new AbstractValue(buffer);
+ clean.AddTaint();
+ }
+
[Test]
public void AssignmentAtByteZero()
{
- var buffer = AbstractValue.GetNewBuffer(16);
+ AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
pointer = new AbstractValue(buffer);
pointer.PointsTo[0] = new AbstractValue(0x31337);
Assert.AreEqual(0x31337, pointer.PointsTo[0].Value);
@@ -64,96 +65,91 @@
pointer = new AbstractValue(buffer);
pointer.PointsTo[15] = new AbstractValue(0x31337);
Assert.AreEqual(0x31337, pointer.PointsTo[15].Value);
- }
-
+ }
+
[Test]
- [ExpectedException(typeof(ArgumentException))]
- public void ZeroSizeBuffer()
+ public void CheckOOBAfterCopy()
{
- pointer = new AbstractValue(new AbstractValue[] {});
- }
+ var src = new AbstractValue(0x31337);
+ src.IsOOB = false;
+ var dest = new AbstractValue(0x1);
+ dest.IsOOB = true;
+ dest = new AbstractValue(src);
- [Test]
- [ExpectedException(typeof(ArgumentNullException))]
- public void NullCopyCtor()
- {
- pointer = new AbstractValue((AbstractValue)null);
+ Assert.IsFalse(dest.IsOOB);
}
[Test]
- public void TruncateValue()
+ [ExpectedException(typeof (ArgumentException))]
+ public void EmptyBuffer()
{
- AbstractValue dwordValue = new AbstractValue(0xdeadbeef);
- AbstractValue byteValue = dwordValue.TruncateValueToByte();
- Assert.AreEqual(0xef, byteValue.Value);
- }
-
+ pointer = new AbstractValue(new AbstractBuffer(new AbstractValue[] {}));
+ }
+
[Test]
- public void AddTaintIf()
+ public void Equals()
{
- AbstractValue clean = new AbstractValue(0x31337);
- Assert.IsFalse(clean.IsTainted);
- AbstractValue notTainted = clean.AddTaintIf(0 == 1);
- Assert.IsFalse(notTainted.IsTainted);
- Assert.AreSame(clean, notTainted);
-
- AbstractValue tainted = clean.AddTaintIf(1 == 1);
- Assert.IsTrue(tainted.IsTainted);
- Assert.AreNotSame(clean, tainted);
- }
-
+ Assert.IsFalse(new AbstractValue().Equals(null));
+ }
+
[Test]
- public void AddTaint()
+ public void Initialized()
{
- AbstractValue clean = new AbstractValue(0x31337);
- Assert.IsFalse(clean.IsTainted);
- AbstractValue tainted = clean.AddTaint();
- Assert.IsTrue(tainted.IsTainted);
- Assert.AreNotSame(clean, tainted);
+ var uninit = new AbstractValue(0xabcdef);
+ Assert.IsTrue(uninit.IsInitialized);
+ Assert.AreEqual(0xabcdef, uninit.Value);
}
[Test]
- [ExpectedException(typeof(InvalidOperationException))]
- public void AddTaintOnPointer()
- {
- AbstractBuffer buffer = new AbstractBuffer(AbstractValue.GetNewBuffer(1));
- AbstractValue clean = new AbstractValue(buffer);
- clean.AddTaint();
- }
-
- [Test]
- [ExpectedException(typeof(ArgumentException))]
- public void EmptyBuffer()
- {
- pointer = new AbstractValue(new AbstractBuffer(new AbstractValue[] {}));
- }
-
- [Test]
public void NoPointer()
{
AbstractValue value = new AbstractValue(2).AddTaint();
Assert.IsNull(value.PointsTo);
StringAssert.Contains("0x00000002", value.ToString());
- StringAssert.Contains("t", value.ToString());
-
+ StringAssert.Contains("t", value.ToString());
+ }
+
+ [Test]
+ public void NotInitialized()
+ {
+ var uninitializedValue = new AbstractValue();
+ Assert.IsFalse(uninitializedValue.IsInitialized);
+ Assert.AreEqual(AbstractValue.UNKNOWN, uninitializedValue.Value);
+ Assert.AreEqual("?", uninitializedValue.ToString());
+ }
+
+ [Test]
+ [ExpectedException(typeof (ArgumentNullException))]
+ public void NullCopyCtor()
+ {
+ pointer = new AbstractValue((AbstractValue) null);
}
[Test]
public void Pointer()
{
- buffer = new AbstractBuffer(new AbstractValue[] {new AbstractValue(2)});
+ buffer = new AbstractBuffer(new[] {new AbstractValue(2)});
pointer = new AbstractValue(buffer);
Assert.AreEqual(2, pointer.PointsTo[0].Value);
StringAssert.StartsWith("*0x00000002", pointer.ToString());
+ }
+
+ [Test]
+ public void PointerHashcodes()
+ {
+ pointer = new AbstractValue(new[] {new AbstractValue(1)});
+ var pointer2 = new AbstractValue(new[] {new AbstractValue(2)});
+
+ Assert.AreNotEqual(pointer.GetHashCode(), pointer2.GetHashCode());
}
[Test]
public void PointerPointer()
{
- buffer = new AbstractBuffer(new AbstractValue[] {new AbstractValue(2)});
+ buffer = new AbstractBuffer(new[] {new AbstractValue(2)});
pointer = new AbstractValue(buffer);
- AbstractValue pointerPointer = new AbstractValue(new AbstractValue[] {pointer});
+ var pointerPointer = new AbstractValue(new[] {pointer});
Assert.AreEqual(2, pointerPointer.PointsTo[0].PointsTo[0].Value);
StringAssert.StartsWith("**0x00000002", pointerPointer.ToString());
}
@@ -161,32 +157,20 @@
[Test]
public void PointerPointerPointer()
{
- buffer = new AbstractBuffer(new AbstractValue[] {new AbstractValue(2)});
+ buffer = new AbstractBuffer(new[] {new AbstractValue(2)});
pointer = new AbstractValue(buffer);
- AbstractValue pointerPointer = new AbstractValue(new AbstractValue[] {pointer});
- AbstractValue pointerPointerPointer = new AbstractValue(new AbstractValue[] {pointerPointer});
+ var pointerPointer = new AbstractValue(new[] {pointer});
+ var pointerPointerPointer = new AbstractValue(new[] {pointerPointer});
Assert.AreEqual(2, pointerPointerPointer.PointsTo[0].PointsTo[0].PointsTo[0].Value);
StringAssert.StartsWith("***0x00000002", pointerPointerPointer.ToString());
}
[Test]
- public void CheckOOBAfterCopy()
- {
- AbstractValue src = new AbstractValue(0x31337);
- src.IsOOB = false;
- AbstractValue dest = new AbstractValue(0x1);
- dest.IsOOB = true;
- dest = new AbstractValue(src);
-
- Assert.IsFalse(dest.IsOOB);
- }
-
- [Test]
public void PreserveIsOOBAfterCopy()
{
- AbstractValue src = new AbstractValue(0x31337);
- AbstractValue dest = new AbstractValue(0x1);
+ var src = new AbstractValue(0x31337);
+ var dest = new AbstractValue(0x1);
src.IsOOB = true;
dest = new AbstractValue(src);
@@ -194,10 +178,25 @@
}
[Test]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
+ [ExpectedException(typeof (ArgumentOutOfRangeException))]
public void RequestedBufferTooLarge()
{
AbstractValue.GetNewBuffer(AbstractValue.MAX_BUFFER_SIZE + 1);
+ }
+
+ [Test]
+ public void TruncateValue()
+ {
+ var dwordValue = new AbstractValue(0xdeadbeef);
+ AbstractValue byteValue = dwordValue.TruncateValueToByte();
+ Assert.AreEqual(0xef, byteValue.Value);
+ }
+
+ [Test]
+ [ExpectedException(typeof (ArgumentException))]
+ public void ZeroSizeBuffer()
+ {
+ pointer = new AbstractValue(new AbstractValue[] {});
}
}
-}
+}
\ No newline at end of file
Modified: Analyzer.cs
===================================================================
--- Analyzer.cs 2009-01-29 05:14:45 UTC (rev 163)
+++ Analyzer.cs 2009-01-29 05:41:37 UTC (rev 164)
@@ -4,15 +4,15 @@
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
-using System;
-using System.Collections.ObjectModel;
-
+using System;
+using System.Collections.ObjectModel;
+
namespace bugreport
{
public class EmulationEventArgs : EventArgs
{
+ private readonly ReadOnlyCollection<Byte> code;
private readonly MachineState state;
- private readonly ReadOnlyCollection<Byte> code;
public EmulationEventArgs(MachineState state, ReadOnlyCollection<Byte> code)
{
@@ -63,11 +63,11 @@
public class Analyzer
{
+ private readonly Opcode opcode = new X86Opcode();
+ private readonly IParsable parser;
public EventHandler<EmulationEventArgs> OnEmulationComplete;
protected ReportCollection reportItems;
- private readonly IParsable parser;
- private readonly Opcode opcode = new X86Opcode();
public Analyzer(IParsable parser)
{
@@ -83,18 +83,12 @@
public ReadOnlyCollection<ReportItem> ActualReportItems
{
- get
- {
- return new ReadOnlyCollection<ReportItem>(reportItems);
- }
+ get { return new ReadOnlyCollection<ReportItem>(reportItems); }
}
public ReadOnlyCollection<ReportItem> ExpectedReportItems
{
- get
- {
- return parser.ExpectedReportItems;
- }
+ get { return parser.ExpectedReportItems; }
}
public EventHandler<ReportEventArgs> OnReport
@@ -106,17 +100,17 @@
private static RegisterCollection getRegistersForLinuxStart()
{
- RegisterCollection linuxMainDefaultValues = new RegisterCollection();
+ var linuxMainDefaultValues = new RegisterCollection();
AbstractValue arg0 = new AbstractValue(1).AddTaint();
- AbstractValue[] argvBuffer = new AbstractValue[] {arg0};
- AbstractValue argvPointer = new AbstractValue(argvBuffer);
- AbstractValue[] argvPointerBuffer = new AbstractValue[] {argvPointer};
- AbstractValue argvPointerPointer = new AbstractValue(argvPointerBuffer);
- AbstractValue[] stackBuffer = AbstractValue.GetNewBuffer(0x200);
+ var argvBuffer = new[] {arg0};
+ var argvPointer = new AbstractValue(argvBuffer);
+ var argvPointerBuffer = new[] {argvPointer};
+ var argvPointerPointer = new AbstractValue(argvPointerBuffer);
+ AbstractValue[] stackBuffer = AbstractValue.GetNewBuffer(0x200);
- AbstractBuffer buffer = new AbstractBuffer(stackBuffer);
+ var buffer = new AbstractBuffer(stackBuffer);
AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(0x100));
// linux ABI dictates
@@ -125,7 +119,7 @@
// gcc generates code that accesses this at some optimization levels
modifiedBuffer[0xfc] = new AbstractValue(1);
- AbstractValue stackPointer = new AbstractValue(modifiedBuffer);
+ var stackPointer = new AbstractValue(modifiedBuffer);
linuxMainDefaultValues[RegisterName.ESP] = stackPointer;
return linuxMainDefaultValues;
@@ -139,41 +133,42 @@
public void Run()
{
- MachineState machineState = new MachineState(getRegistersForLinuxStart());
+ var machineState = new MachineState(getRegistersForLinuxStart());
machineState.InstructionPointer = parser.EntryPointAddress;
Byte[] instructions = parser.GetBytes();
UInt32 index = machineState.InstructionPointer - parser.BaseAddress;
-
+
while (index < instructions.Length)
{
MachineState savedState = machineState;
Byte[] instruction = extractInstruction(instructions, index);
-
+
machineState = runCode(machineState, instruction);
if (null != OnEmulationComplete)
{
- OnEmulationComplete(this, new EmulationEventArgs(savedState, new ReadOnlyCollection<Byte>(instruction)));
+ OnEmulationComplete(
+ this, new EmulationEventArgs(savedState, new ReadOnlyCollection<Byte>(instruction)));
}
-
+
index = machineState.InstructionPointer - parser.BaseAddress;
-
+
if (opcode.TerminatesFunction(instruction))
{
break;
}
}
}
-
+
private Byte[] extractInstruction(Byte[] instructions, UInt32 index)
{
Byte instructionLength = opcode.GetInstructionLength(instructions, index);
- Byte[] instruction = new Byte[instructionLength];
- for (UInt32 count=index; count < index+instructionLength; count++)
+ var instruction = new Byte[instructionLength];
+ for (UInt32 count = index; count < index + instructionLength; count++)
{
- instruction[count-index] = instructions[count];
+ instruction[count - index] = instructions[count];
}
-
+
return instruction;
}
}
-}
+}
\ No newline at end of file
Modified: AnalyzerTest.cs
===================================================================
--- AnalyzerTest.cs 2009-01-29 05:14:45 UTC (rev 163)
+++ AnalyzerTest.cs 2009-01-29 05:41:37 UTC (rev 164)
@@ -4,20 +4,20 @@
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
-using System;
-using NUnit.Framework;
-using NUnit.Mocks;
-using System.IO;
-using System.Collections.Generic;
-
+using System;
+using System.Collections.Generic;
+using System.IO;
+using NUnit.Framework;
+using NUnit.Mocks;
+
namespace bugreport
{
[TestFixture]
public sealed class AnalyzerTest : IDisposable
{
- Analyzer analyzer;
- readonly MemoryStream stream = new MemoryStream(new Byte[] {0, 1, 2});
- readonly Byte[] code = new Byte[] {0x90};
+ private Analyzer analyzer;
+ private readonly MemoryStream stream = new MemoryStream(new Byte[] {0, 1, 2});
+ private readonly Byte[] code = new Byte[] {0x90};
private class FakeAnalyzer : Analyzer
{
@@ -36,7 +36,7 @@
reportItems.Add(new ReportItem(i, false));
}
- _machineState.InstructionPointer += (UInt32)_instructionBytes.Length;
+ _machineState.InstructionPointer += (UInt32) _instructionBytes.Length;
return _machineState;
}
@@ -52,10 +52,10 @@
private IParsable createMockParser(UInt32 expectedReportItemCount)
{
- DynamicMock control = new DynamicMock(typeof(IParsable));
+ var control = new DynamicMock(typeof (IParsable));
control.ExpectAndReturn("GetBytes", code, null);
- List<ReportItem> reportItemList = new List<ReportItem>();
+ var reportItemList = new List<ReportItem>();
for (UInt32 i = 0; i < expectedReportItemCount; i++)
{
@@ -67,7 +67,16 @@
}
[Test]
- [ExpectedException(typeof(ArgumentNullException))]
+ public void NoReportItems()
+ {
+ analyzer = new Analyzer(createMockParser(0));
+ Assert.AreEqual(0, analyzer.ActualReportItems.Count);
+ analyzer.Run();
+ Assert.AreEqual(0, analyzer.ExpectedReportItems.Count);
+ }
+
+ [Test]
+ [ExpectedException(typeof (ArgumentNullException))]
public void NullStream()
{
analyzer = new Analyzer(null);
@@ -75,18 +84,21 @@
}
[Test]
- public void NoReportItems()
+ public void VerifyExpectedAndActualReports()
{
- analyzer = new Analyzer(createMockParser(0));
- Assert.AreEqual(0, analyzer.ActualReportItems.Count);
+ analyzer = new FakeAnalyzer(createMockParser(2), 2);
analyzer.Run();
- Assert.AreEqual(0, analyzer.ExpectedReportItems.Count);
- }
+ Assert.AreEqual(analyzer.ActualReportItems.Count, analyzer.ExpectedReportItems.Count);
+ analyzer = new FakeAnalyzer(createMockParser(2), 3);
+ analyzer.Run();
+ Assert.AreNotEqual(analyzer.ActualReportItems.Count, analyzer.ExpectedReportItems.Count);
+ }
+
[Test]
public void WithReportItems()
{
- List<ReportItem> reportItems = new List<ReportItem>();
+ var reportItems = new List<ReportItem>();
analyzer = new FakeAnalyzer(createMockParser(2), 2);
analyzer.OnEmulationComplete +=
@@ -97,10 +109,7 @@
};
analyzer.OnReport +=
- delegate(object sender, ReportEventArgs e)
- {
- reportItems.Add(e.ReportItem);
- };
+ delegate(object sender, ReportEventArgs e) { reportItems.Add(e.ReportItem); };
analyzer.Run();
Assert.AreEqual(2, analyzer.ActualReportItems.Count);
@@ -109,17 +118,5 @@
Assert.AreEqual(0, reportItems[0].InstructionPointer);
Assert.AreEqual(1, reportItems[1].InstructionPointer);
}
-
- [Test]
- public void VerifyExpectedAndActualReports()
- {
- analyzer = new FakeAnalyzer(createMockParser(2), 2);
- analyzer.Run();
- Assert.AreEqual(analyzer.ActualReportItems.Count, analyzer.ExpectedReportItems.Count);
-
- analyzer = new FakeAnalyzer(createMockParser(2), 3);
- analyzer.Run();
- Assert.AreNotEqual(analyzer.ActualReportItems.Count, analyzer.ExpectedReportItems.Count);
- }
}
-}
+}
\ No newline at end of file
Modified: ArmEmulator.cs
===================================================================
--- ArmEmulator.cs 2009-01-29 05:14:45 UTC (rev 163)
+++ ArmEmulator.cs 2009-01-29 05:41:37 UTC (rev 164)
@@ -4,15 +4,9 @@
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Text;
-
namespace bugreport
{
public static class ArmEmulator
- {
-
+ {
}
}
\ No newline at end of file
Modified: ArmEmulatorTest.cs
===================================================================
--- ArmEmulatorTest.cs 2009-01-29 05:14:45 UTC (rev 163)
+++ ArmEmulatorTest.cs 2009-01-29 05:41:37 UTC (rev 164)
@@ -4,14 +4,12 @@
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
-using System;
-using NUnit.Framework;
-
+using NUnit.Framework;
+
namespace bugreport
{
[TestFixture]
public class ArmEmulatorTest
- {
-
+ {
}
}
\ No newline at end of file
Modified: AssemblyInfo.cs
===================================================================
--- AssemblyInfo.cs 2009-01-29 05:14:45 UTC (rev 163)
+++ AssemblyInfo.cs 2009-01-29 05:41:37 UTC (rev 164)
@@ -4,15 +4,15 @@
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+[assembly : ComVisible(false)]
-[assembly: ComVisible(false)]
-
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
-// You can specify all values by your own or you can build default build and revision
-[assembly: AssemblyVersion("0.1.*")]
+// You can specify all values by your own or you can build default build and revision
+
+[assembly : AssemblyVersion("0.1.*")]
\ No newline at end of file
Modified: BitMath.cs
===================================================================
--- BitMath.cs 2009-01-29 05:14:45 UTC (rev 163)
+++ BitMath.cs 2009-01-29 05:41:37 UTC (rev 164)
@@ -4,8 +4,8 @@
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
-using System;
-
+using System;
+
namespace bugreport
{
public static class BitMath
@@ -16,15 +16,16 @@
if (data.Length < index + 4)
{
- throw new ArgumentException(String.Format("Not enough bytes for DWORD: need {0}, got {1}", index + 4, data.Length), "data");
+ throw new ArgumentException(
+ String.Format("Not enough bytes for DWORD: need {0}, got {1}", index + 4, data.Length), "data");
}
-
+
for (Byte i = 0; i < 4; ++i)
{
- result |= (UInt32) (data[i + index]) << (8*i);
+ result |= (UInt32) (data[i + index]) << (8 * i);
}
return result;
}
}
-}
+}
\ No newline at end of file
Modified: BitMathTest.cs
===================================================================
--- BitMathTest.cs 2009-01-29 05:14:45 UTC (rev 163)
+++ BitMathTest.cs 2009-01-29 05:41:37 UTC (rev 164)
@@ -4,47 +4,47 @@
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
-using System;
-using NUnit.Framework;
-
+using System;
+using NUnit.Framework;
+
namespace bugreport
{
[TestFixture]
public class BitMathTest
- {
+ {
[Test]
- [ExpectedException(typeof(ArgumentException))]
- public void NotEnoughBytesToDwordAtZeroIndex()
+ public void AllZeroes()
{
- BitMath.BytesToDword(new Byte[] {0}, 0);
- }
-
+ UInt32 result = BitMath.BytesToDword(new Byte[] {0, 0, 0, 0}, 0);
+ Assert.AreEqual(0, result);
+ }
+
[Test]
- [ExpectedException(typeof(ArgumentException))]
+ [ExpectedException(typeof (ArgumentException))]
+ public void EmptyBytes()
+ {
+ BitMath.BytesToDword(new Byte[] {}, 0);
+ }
+
+ [Test]
+ [ExpectedException(typeof (ArgumentException))]
public void NotEnoughBytesToDwordAtNonZeroIndex()
{
BitMath.BytesToDword(new Byte[] {0, 1, 2, 3}, 1);
- }
-
+ }
+
[Test]
- [ExpectedException(typeof(ArgumentException))]
- public void EmptyBytes()
+ [ExpectedException(typeof (ArgumentException))]
+ public void NotEnoughBytesToDwordAtZeroIndex()
{
- BitMath.BytesToDword(new Byte[] {}, 0);
+ BitMath.BytesToDword(new Byte[] {0}, 0);
}
[Test]
- public void AllZeroes()
- {
- UInt32 result = BitMath.BytesToDword(new Byte[] {0, 0, 0, 0}, 0);
- Assert.AreEqual(0, result);
- }
-
- [Test]
public void OneTwoThreeFour()
{
UInt32 result = BitMath.BytesToDword(new Byte[] {1, 2, 3, 4}, 0);
Assert.AreEqual(0x04030201, result);
}
}
-}
+}
\ No newline at end of file
Modified: Contract.cs
===================================================================
--- Contract.cs 2009-01-29 05:14:45 UTC (rev 163)
+++ Contract.cs 2009-01-29 05:41:37 UTC (rev 164)
@@ -4,8 +4,8 @@
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
-using System;
-
+using System;
+
namespace bugreport
{
public abstract class Contract
@@ -15,4 +15,4 @@
public abstract Boolean IsSatisfiedBy(MachineState state, Byte[] code);
public abstract MachineState Execute(MachineState state);
}
-}
+}
\ No newline at end of file
Modified: CoverageExcludeAttribute.cs
===================================================================
--- CoverageExcludeAttribute.cs 2009-01-29 05:14:45 UTC (rev 163)
+++ CoverageExcludeAttribute.cs 2009-01-29 05:41:37 UTC (rev 164)
@@ -4,10 +4,12 @@
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
-using System;
-
+using System;
+
namespace bugreport
{
[AttributeUsage(AttributeTargets.Method)]
- public sealed class CoverageExcludeAttribute : Attribute {}
-}
+ public sealed class CoverageExcludeAttribute : Attribute
+ {
+ }
+}
\ No newline at end of file
Modified: DebuggerCommandTest.cs
===================================================================
--- DebuggerCommandTest.cs 2009-01-29 05:14:45 UTC (rev 163)
+++ DebuggerCommandTest.cs 2009-01-29 05:41:37 UTC (rev 164)
@@ -4,8 +4,8 @@
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
-using NUnit.Framework;
-
+using NUnit.Framework;
+
namespace bugreport
{
[TestFixture]
@@ -19,6 +19,16 @@
command = new DebuggerCommand("NOTdisasm");
Assert.IsFalse(command.IsDisassemble);
+ }
+
+ [Test]
+ public void IsEnter()
+ {
+ var command = new DebuggerCommand("");
+ Assert.IsTrue(command.IsEnter);
+
+ command = new DebuggerCommand("NOT");
+ Assert.IsFalse(command.IsEnter);
}
[Test]
@@ -29,8 +39,8 @@
command = new DebuggerCommand("NOTq");
Assert.IsFalse(command.IsQuit);
- }
-
+ }
+
[Test]
public void IsStackPrint()
{
@@ -39,16 +49,6 @@
command = new DebuggerCommand("NOTp");
Assert.IsFalse(command.IsStackPrint);
- }
-
- [Test]
- public void IsEnter()
- {
- var command = new DebuggerCommand("");
- Assert.IsTrue(command.IsEnter);
-
- command = new DebuggerCommand("NOT");
- Assert.IsFalse(command.IsEnter);
- }
+ }
}
}
\ No newline at end of file
Modified: DebuggerView.cs
===================================================================
--- DebuggerView.cs 2009-01-29 05:14:45 UTC (rev 163)
+++ DebuggerView.cs 2009-01-29 05:41:37 UTC (rev 164)
@@ -4,11 +4,11 @@
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
-using System;
-
+using System;
+
namespace bugreport
{
- class DebuggerView
+ internal class DebuggerView
{
private readonly Boolean interactive;
private MachineState state;
@@ -58,15 +58,15 @@
Console.WriteLine(encoding);
}
- Byte[] getCodeFor(EmulationEventArgs e)
+ private Byte[] getCodeFor(EmulationEventArgs e)
{
- Byte[] code = new Byte[e.Code.Count];
+ var code = new Byte[e.Code.Count];
e.Code.CopyTo(code, 0);
return code;
}
- string getEffectiveAddressFor(EmulationEventArgs e)
+ private string getEffectiveAddressFor(EmulationEventArgs e)
{
state = e.MachineState;
String address = String.Format("{0:x8}", state.InstructionPointer);
@@ -82,7 +82,7 @@
{
while (!enterPressed)
{
- var input = getInput();
+ string input = getInput();
var command = new DebuggerCommand(input);
if (command.IsEnter)
{
@@ -96,8 +96,8 @@
}
if (command.IsDisassemble)
{
- var hex = input.Substring("disasm".Length + 1);
- var code = DumpFileParser.getByteArrayFromHexString(hex);
+ string hex = input.Substring("disasm".Length + 1);
+ byte[] code = DumpFileParser.getByteArrayFromHexString(hex);
printOpcodeInfo(code);
continue;
}
@@ -120,10 +120,10 @@
private void printStackFor(MachineState state)
{
AbstractValue esp = state.Registers[RegisterName.ESP];
-
+
Console.WriteLine("Stack dump");
Console.WriteLine("esp-8\t\t esp-4\t\t esp");
Console.WriteLine("{0}\t\t {1}\t\t {2}", esp.PointsTo[-2], esp.PointsTo[-1], esp.PointsTo[0]);
}
}
-}
+}
\ No newline at end of file
Modified: DumpFileParser.cs
===================================================================
--- DumpFileParser.cs 2009-01-29 05:14:45 UTC (rev 163)
+++ DumpFileParser.cs 2009-01-29 05:41:37 UTC (rev 164)
@@ -4,12 +4,12 @@
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.IO;
-using System.Globalization;
-
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Globalization;
+using System.IO;
+
namespace bugreport
{
public interface IParsable
@@ -18,19 +18,20 @@
UInt32 BaseAddress { get; }
UInt32 EntryPointAddress { get; }
-
- Byte [] GetBytes();
+
+ Byte[] GetBytes();
}
public sealed class DumpFileParser : IParsable, IDisposable
{
- private readonly Stream stream;
- private readonly StreamReader reader;
- private Boolean inTextSection;
- private readonly List<Byte[]> opCodeList;
private readonly List<ReportItem> expectedReportItems;
- private UInt32 entryPointAddress, baseAddress;
- private readonly String functionNameToParse = "main";
+ private readonly String functionNameToParse = "main";
+ private readonly List<Byte[]> opCodeList;
+ private readonly StreamReader reader;
+ private readonly Stream stream;
+ private UInt32 baseAddress;
+ private UInt32 entryPointAddress;
+ private Boolean inTextSection;
public DumpFileParser(Stream stream, String functionNameToParse)
{
@@ -40,16 +41,22 @@
reader = new StreamReader(this.stream);
expectedReportItems = new List<ReportItem>();
opCodeList = parse();
- }
-
+ }
+
+ #region IDisposable Members
+
public void Dispose()
{
if (null != reader)
{
reader.Dispose();
}
- }
-
+ }
+
+ #endregion
+
+ #region IParsable Members
+
public Byte[] GetBytes()
{
if (opCodeList.Count == 0)
@@ -58,31 +65,28 @@
}
Int32 total = 0;
- foreach (Byte[] bytes in opCodeList)
+ foreach (var bytes in opCodeList)
{
total += bytes.Length;
}
int allByteCount = 0;
- Byte[] allBytes = new Byte[total];
- foreach (Byte[] bytes in opCodeList)
+ var allBytes = new Byte[total];
+ foreach (var bytes in opCodeList)
{
- for (int i=0;i<bytes.Length;i++)
+ for (int i = 0; i < bytes.Length; i++)
{
- allBytes[i+allByteCount] = bytes[i];
+ allBytes[i + allByteCount] = bytes[i];
}
- allByteCount+=bytes.Length;
+ allByteCount += bytes.Length;
}
return allBytes;
- }
+ }
public ReadOnlyCollection<ReportItem> ExpectedReportItems
{
- get
- {
- return expectedReportItems.AsReadOnly();
- }
+ get { return expectedReportItems.AsReadOnly(); }
}
public UInt32 BaseAddress
@@ -93,11 +97,13 @@
public UInt32 EntryPointAddress
{
get { return entryPointAddress; }
- }
-
+ }
+
+ #endregion
+
private static UInt32 getAddressForLine(String line)
{
- String address = line.Substring(0,8);
+ String address = line.Substring(0, 8);
return UInt32.Parse(address, NumberStyles.HexNumber);
}
@@ -111,7 +117,7 @@
inTextSection = true;
}
- if (line.Contains("<" + functionNameToParse +">:"))
+ if (line.Contains("<" + functionNameToParse + ">:"))
{
entryPointAddress = getAddressForLine(line);
}
@@ -131,12 +137,12 @@
return null;
}
- String afterColonToEnd = line.Substring(colonIndex+1).Trim();
+ String afterColonToEnd = line.Substring(colonIndex + 1).Trim();
Int32 doubleSpaceIndex = afterColonToEnd.IndexOf(" ", StringComparison.Ordinal);
Int32 spaceTabIndex = afterColonToEnd.IndexOf(" \t", StringComparison.Ordinal);
Int32 endOfHexIndex;
- if ( doubleSpaceIndex >= 0 && spaceTabIndex >= 0)
+ if (doubleSpaceIndex >= 0 && spaceTabIndex >= 0)
{
endOfHexIndex = doubleSpaceIndex < spaceTabIndex ? doubleSpaceIndex : spaceTabIndex;
}
@@ -157,9 +163,9 @@
public static Byte[] getByteArrayFromHexString(String hex)
{
- String[] hexStrings = hex.Split(new Char[] {' '});
+ String[] hexStrings = hex.Split(new[] {' '});
- Byte[] hexBytes = new Byte[hexStrings.Length];
+ var hexBytes = new Byte[hexStrings.Length];
for (Int32 i = 0; i < hexStrings.Length; ++i)
{
@@ -170,8 +176,7 @@
}
private static Byte[] getHexFromString(String line)
- {
-
+ {
if (line.Trim().Length == 0)
return null;
@@ -187,7 +192,7 @@
private List<Byte[]> parse()
...
[truncated message content] |
|
From: <mat...@us...> - 2009-01-29 05:15:23
|
Revision: 163
http://bugreport.svn.sourceforge.net/bugreport/?rev=163&view=rev
Author: matt_hargett
Date: 2009-01-29 05:14:45 +0000 (Thu, 29 Jan 2009)
Log Message:
-----------
Mike and Matt - cleaned up some StyleCop warnings, made stack emulation more accurate. Next step: fix mov esp,ebp
Modified Paths:
--------------
AbstractBuffer.cs
AbstractBufferTest.cs
AnalysisEngine.csproj
ArmOpcodeTest.cs
MachineState.cs
MachineStateTest.cs
X86EmulatorTest.cs
Modified: AbstractBuffer.cs
===================================================================
--- AbstractBuffer.cs 2009-01-05 02:29:05 UTC (rev 162)
+++ AbstractBuffer.cs 2009-01-29 05:14:45 UTC (rev 163)
@@ -9,10 +9,10 @@
namespace bugreport
{
public class AbstractBuffer
- {
+ {
+ private readonly Int32 allocatedLength;
private AbstractValue[] storage;
private UInt32 baseIndex;
- private readonly Int32 allocatedLength;
public AbstractBuffer(AbstractValue[] _buffer)
{
@@ -26,36 +26,57 @@
allocatedLength = _copyMe.allocatedLength;
storage = new AbstractValue[_copyMe.storage.Length];
Array.Copy(_copyMe.storage, storage, _copyMe.storage.Length);
+ }
+
+ public AbstractValue this[Int32 index]
+ {
+ get
+ {
+ // We check this.storage.Length as well so that we aren't calling Extend() when we dont need to.
+ if (IsIndexPastBounds(index))
+ {
+ extend(baseIndex + (UInt32)index);
+ return storage[baseIndex + index];
+ }
+
+ return storage[baseIndex + index];
+ }
+
+ set
+ {
+ if ((baseIndex + index) >= allocatedLength)
+ {
+ value.IsOOB = true;
+ }
+
+ if (IsIndexPastBounds(index))
+ {
+ extend(baseIndex + (UInt32)index);
+ storage[baseIndex + index] = value;
+ }
+ else
+ {
+ storage[baseIndex + index] = value;
+ }
+ }
+ }
+
+ public UInt32 BaseIndex
+ {
+ get { return baseIndex; }
+ }
+
+ public Int32 Length
+ {
+ get { return allocatedLength; }
}
- private void extend(UInt32 _newLength)
- {
- // Account for element [0] of the array
- _newLength = _newLength + 1;
- if (_newLength >= Length)
- {
- AbstractValue[] _copyTo = new AbstractValue[_newLength];
-
- Int32 i;
- for (i = 0; i < storage.Length; i++)
- {
- _copyTo[i] = storage[i];
- }
- for (; i < _newLength; i++)
- {
- _copyTo[i] = new AbstractValue(AbstractValue.UNKNOWN);
- _copyTo[i].IsOOB = true;
- }
- storage = _copyTo;
- }
-
- return;
- }
-
public AbstractBuffer DoOperation(OperatorEffect _operatorEffect, AbstractValue _rhs)
{
AbstractBuffer lhs = this;
+
// TODO: should have a guard for if _rhs isnt a pointer
+
switch (_operatorEffect)
{
case OperatorEffect.Assignment:
@@ -64,6 +85,7 @@
return result;
}
+
case OperatorEffect.Add:
{
AbstractBuffer result = new AbstractBuffer(lhs);
@@ -96,56 +118,37 @@
default:
throw new ArgumentException(String.Format("Unsupported OperatorEffect: {0}", _operatorEffect), "_operatorEffect");
}
- }
-
+ }
+
private Boolean IsIndexPastBounds(Int32 index)
{
return (((baseIndex + index) >= allocatedLength) && ((baseIndex + index) >= storage.Length));
+ }
+
+ private void extend(UInt32 _newLength)
+ {
+ // Account for element [0] of the array
+ _newLength = _newLength + 1;
+ if (_newLength >= Length)
+ {
+ AbstractValue[] _copyTo = new AbstractValue[_newLength];
+
+ Int32 i;
+ for (i = 0; i < storage.Length; i++)
+ {
+ _copyTo[i] = storage[i];
+ }
+
+ for (; i < _newLength; i++)
+ {
+ _copyTo[i] = new AbstractValue(AbstractValue.UNKNOWN);
+ _copyTo[i].IsOOB = true;
+ }
+
+ storage = _copyTo;
+ }
+
+ return;
}
-
- public AbstractValue this[Int32 index]
- {
- get
- {
- // We check this.storage.Length as well so that we aren't calling Extend() when we dont need to.
- if (IsIndexPastBounds(index))
- {
- extend(baseIndex + (UInt32)index);
- return storage[baseIndex + index];
- }
- else
- {
- return storage[baseIndex + index];
- }
- }
-
- set
- {
- if ((baseIndex + index) >= allocatedLength)
- {
- value.IsOOB = true;
- }
-
- if (IsIndexPastBounds(index))
- {
- extend(baseIndex + (UInt32)index);
- storage[baseIndex + index] = value;
- }
- else
- {
- storage[baseIndex + index] = value;
- }
- }
- }
-
- public UInt32 BaseIndex
- {
- get { return baseIndex; }
- }
-
- public Int32 Length
- {
- get { return allocatedLength; }
- }
}
}
Modified: AbstractBufferTest.cs
===================================================================
--- AbstractBufferTest.cs 2009-01-05 02:29:05 UTC (rev 162)
+++ AbstractBufferTest.cs 2009-01-29 05:14:45 UTC (rev 163)
@@ -42,18 +42,17 @@
AbstractValue two = new AbstractValue(0x2);
AbstractValue three = new AbstractValue(0x3);
AbstractValue four = new AbstractValue(0x4);
- AbstractValue[] avBuffer = AbstractValue.GetNewBuffer(4);
+ AbstractValue[] values = AbstractValue.GetNewBuffer(4);
- avBuffer[0] = one;
- avBuffer[1] = two;
- avBuffer[2] = three;
- avBuffer[3] = four;
+ values[0] = one;
+ values[1] = two;
+ values[2] = three;
+ values[3] = four;
- AbstractBuffer buffer = new AbstractBuffer(avBuffer);
+ AbstractBuffer buffer = new AbstractBuffer(values);
Assert.AreEqual(one, buffer[0]);
AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(2));
Assert.AreEqual(three, modifiedBuffer[0]);
-
}
[Test]
@@ -63,14 +62,14 @@
AbstractValue two = new AbstractValue(0x2);
AbstractValue three = new AbstractValue(0x3);
AbstractValue four = new AbstractValue(0x4);
- AbstractValue[] avBuffer = AbstractValue.GetNewBuffer(4);
+ AbstractValue[] values = AbstractValue.GetNewBuffer(4);
- avBuffer[0] = one;
- avBuffer[1] = two;
- avBuffer[2] = three;
- avBuffer[3] = four;
+ values[0] = one;
+ values[1] = two;
+ values[2] = three;
+ values[3] = four;
- AbstractBuffer buffer = new AbstractBuffer(avBuffer);
+ AbstractBuffer buffer = new AbstractBuffer(values);
Assert.AreEqual(one, buffer[0]);
AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(2));
Assert.AreEqual(three, modifiedBuffer[0]);
@@ -125,7 +124,6 @@
new AbstractBuffer(new AbstractValue[] {}).DoOperation(OperatorEffect.Unknown, null);
}
-
[Test]
public void PointerOverflowByOne()
{
@@ -209,7 +207,8 @@
}
[Test]
- public void OverflowZeroSizeBuffer() {
+ public void OverflowZeroSizeBuffer()
+ {
AbstractBuffer f = new AbstractBuffer(new AbstractValue[] {});
Assert.IsFalse(f[0].IsInitialized);
}
Modified: AnalysisEngine.csproj
===================================================================
--- AnalysisEngine.csproj 2009-01-05 02:29:05 UTC (rev 162)
+++ AnalysisEngine.csproj 2009-01-29 05:14:45 UTC (rev 163)
@@ -62,8 +62,6 @@
<Compile Include="AnalyzerTest.cs" />
<Compile Include="ArmEmulator.cs" />
<Compile Include="ArmEmulatorTest.cs" />
- <Compile Include="ArmOpcode.cs" />
- <Compile Include="ArmOpcodeTest.cs" />
<Compile Include="BitMathTest.cs" />
<Compile Include="Contract.cs" />
<Compile Include="CoverageExcludeAttribute.cs" />
Modified: ArmOpcodeTest.cs
===================================================================
--- ArmOpcodeTest.cs 2009-01-05 02:29:05 UTC (rev 162)
+++ ArmOpcodeTest.cs 2009-01-29 05:14:45 UTC (rev 163)
@@ -4,8 +4,8 @@
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
-using System
-using NUnit.Framework
+using System;
+using NUnit.Framework;
namespace bugreport
{
Modified: MachineState.cs
===================================================================
--- MachineState.cs 2009-01-05 02:29:05 UTC (rev 162)
+++ MachineState.cs 2009-01-29 05:14:45 UTC (rev 163)
@@ -175,7 +175,7 @@
public MachineState PushOntoStack(AbstractValue value)
{
- MachineState newState = DoOperation(RegisterName.ESP, OperatorEffect.Add, new AbstractValue(0x1));
+ MachineState newState = DoOperation(RegisterName.ESP, OperatorEffect.Add, new AbstractValue(0x4));
newState.TopOfStack = new AbstractValue(value);
return newState;
}
Modified: MachineStateTest.cs
===================================================================
--- MachineStateTest.cs 2009-01-05 02:29:05 UTC (rev 162)
+++ MachineStateTest.cs 2009-01-29 05:14:45 UTC (rev 163)
@@ -30,7 +30,6 @@
private AbstractValue esp
{
- get { return state.Registers[RegisterName.ESP]; }
set { state.Registers[RegisterName.ESP] = value; }
}
@@ -78,7 +77,7 @@
public void NonAssignmentOfPointer()
{
eax = one;
- ebx = new AbstractValue(new AbstractValue[] {two});
+ ebx = new AbstractValue(new[] {two});
state = state.DoOperation(RegisterName.EAX, OperatorEffect.Add, RegisterName.EBX);
}
@@ -177,22 +176,34 @@
Assert.IsNotNull(eax.PointsTo);
state = state.DoOperation(RegisterName.EAX, OperatorEffect.Sub, RegisterName.EBX);
Assert.AreEqual(one, eax.PointsTo[0]);
- }
-
+ }
+
+ [Test]
+ public void PushPopThenAssignToTop()
+ {
+ AbstractValue[] buffer = AbstractValue.GetNewBuffer(0x20);
+ esp = new AbstractValue(buffer);
+ state = state.PushOntoStack(one);
+
+ //TODO(matt_hargett): extract into state.PopOffStack()
+ state = state.DoOperation(RegisterName.ESP, OperatorEffect.Sub, new AbstractValue(0x4));
+ state = state.DoOperation(RegisterName.ESP, 0, OperatorEffect.Assignment, two);
+ Assert.AreEqual(two, state.TopOfStack);
+ }
+
+ [Test]
+ public void PushTwiceThenManuallyAdjustStack()
+ {
+ AbstractValue[] buffer = AbstractValue.GetNewBuffer(0x20);
+ esp = new AbstractValue(buffer);
+ state = state.PushOntoStack(one);
+ state = state.PushOntoStack(two);
+
+ state = state.DoOperation(RegisterName.ESP, OperatorEffect.Sub, new AbstractValue(0x4));
+ Assert.AreEqual(one, state.TopOfStack);
+ }
+
[Test]
- public void PushPopThenAssignToTop()
- {
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(0x20);
- esp = new AbstractValue(buffer);
- state = state.PushOntoStack(one);
-
- //TODO(matt_hargett): extract into state.PopOffStack()
- state = state.DoOperation(RegisterName.ESP, OperatorEffect.Sub, new AbstractValue(0x1));
- state = state.DoOperation(RegisterName.ESP, 0, OperatorEffect.Assignment, two);
- Assert.AreEqual(two, state.TopOfStack);
- }
-
- [Test]
public void PointerAnd()
{
AbstractValue[] buffer = AbstractValue.GetNewBuffer(0x10);
@@ -238,9 +249,9 @@
[Test]
public void OperationResultEquality()
{
- OperationResult same = new OperationResult(new AbstractValue(1), false);
- OperationResult same2 = new OperationResult(new AbstractValue(1), false);
- OperationResult different = new OperationResult(new AbstractValue(2), true);
+ var same = new OperationResult(new AbstractValue(1), false);
+ var same2 = new OperationResult(new AbstractValue(1), false);
+ var different = new OperationResult(new AbstractValue(2), true);
Assert.IsTrue(same.Equals(same2));
Assert.IsFalse(same.Equals(different));
Modified: X86EmulatorTest.cs
===================================================================
--- X86EmulatorTest.cs 2009-01-05 02:29:05 UTC (rev 162)
+++ X86EmulatorTest.cs 2009-01-29 05:14:45 UTC (rev 163)
@@ -415,7 +415,7 @@
state.InstructionPointer = initialInstructionPointer;
code = new Byte[] {0xe8, 0x14, 0xff, 0xff, 0xff};
state = X86Emulator.Run(reportItems, state, code);
- Assert.AreEqual(initialInstructionPointer + 0x5, state.InstructionPointer);
+ Assert.AreEqual(initialInstructionPointer + code.Length, state.InstructionPointer);
Assert.AreEqual(16, state.ReturnValue.PointsTo.Length);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dm...@us...> - 2009-01-05 02:29:09
|
Revision: 162
http://bugreport.svn.sourceforge.net/bugreport/?rev=162&view=rev
Author: dmoniz
Date: 2009-01-05 02:29:05 +0000 (Mon, 05 Jan 2009)
Log Message:
-----------
*This revision should not be broken (at least in terms of project references, class names, and file names.*
Gardening: Final fix to AnalysisEngine.csproj to point to "new" X86Emulator.cs (done with stupid fix to standardize X86Emulator.cs from X86emulator.cs due to Subversion limitations.)
Modified Paths:
--------------
AnalysisEngine.csproj
Modified: AnalysisEngine.csproj
===================================================================
--- AnalysisEngine.csproj 2009-01-05 02:25:40 UTC (rev 161)
+++ AnalysisEngine.csproj 2009-01-05 02:29:05 UTC (rev 162)
@@ -83,6 +83,7 @@
<Compile Include="MachineState.cs" />
<Compile Include="ModRM.cs" />
<Compile Include="Opcode.cs" />
+ <Compile Include="X86Emulator.cs" />
<Compile Include="X86EmulatorTest.cs" />
<Compile Include="X86OpcodeTest.cs" />
<Compile Include="RegisterCollection.cs" />
@@ -91,7 +92,6 @@
<Compile Include="ReportItemTest.cs" />
<Compile Include="SIB.cs" />
<Compile Include="SIBTests.cs" />
- <Compile Include="X86emulator.cs" />
<Compile Include="X86Opcode.cs" />
</ItemGroup>
</Project>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dm...@us...> - 2009-01-05 02:25:50
|
Revision: 161
http://bugreport.svn.sourceforge.net/bugreport/?rev=161&view=rev
Author: dmoniz
Date: 2009-01-05 02:25:40 +0000 (Mon, 05 Jan 2009)
Log Message:
-----------
Gardening: "add" X86Emulator.cs (stupid fix to standardize X86Emulator.cs from X86emulator.cs due to Subversion limitations.)
Added Paths:
-----------
X86Emulator.cs
Added: X86Emulator.cs
===================================================================
--- X86Emulator.cs (rev 0)
+++ X86Emulator.cs 2009-01-05 02:25:40 UTC (rev 161)
@@ -0,0 +1,347 @@
+// This file is part of bugreport.
+// Copyright (c) 2006-2009 The bugreport Developers.
+// See AUTHORS.txt for details.
+// Licensed under the GNU General Public License, Version 3 (GPLv3).
+// See LICENSE.txt for details.
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Text;
+
+namespace bugreport
+{
+ public class InvalidOpcodeException : Exception
+ {
+ public InvalidOpcodeException(params Byte[] code)
+ : base(FormatOpcodes(code))
+ {
+ }
+
+ public static String FormatOpcodes(params Byte[] code)
+ {
+ StringBuilder message = new StringBuilder("Invalid opcode: ");
+
+
+ foreach (Byte opcode in code)
+ {
+ message.Append(String.Format(" 0x{0:x2}", opcode));
+ }
+
+ return message.ToString();
+ }
+ }
+
+ public static class X86Emulator
+ {
+ private static readonly Opcode opcode = new X86Opcode();
+
+ public static MachineState Run(Collection<ReportItem> reportItemCollector, MachineState machineState, Byte[] code)
+ {
+ if (code.Length == 0)
+ {
+ throw new ArgumentException("Empty array not allowed.", "code");
+ }
+
+ MachineState afterState = emulateOpcode(reportItemCollector, machineState, code);
+
+ if (!branchTaken(machineState, afterState))
+ {
+ afterState.InstructionPointer += opcode.GetInstructionLength(code);
+ }
+ return afterState;
+ }
+
+ private static Boolean branchTaken(MachineState before, MachineState after)
+ {
+ return before.InstructionPointer != after.InstructionPointer;
+ }
+
+ private static MachineState emulateOpcode(ICollection<ReportItem> reportItems, MachineState machineState, Byte[] code)
+ {
+ MachineState state = machineState;
+ RegisterName sourceRegister, destinationRegister;
+ AbstractValue sourceValue;
+ Int32 index;
+
+ OpcodeEncoding encoding = opcode.GetEncoding(code);
+ OperatorEffect op = opcode.GetOperatorEffect(code);
+
+ switch (encoding)
+ {
+ case OpcodeEncoding.rAxIv:
+ case OpcodeEncoding.rAxIz:
+ {
+ destinationRegister = opcode.GetDestinationRegister(code);
+ UInt32 immediate = opcode.GetImmediate(code);
+ state = state.DoOperation(destinationRegister, op, new AbstractValue(immediate));
+ return state;
+ }
+
+ case OpcodeEncoding.rAxOv:
+ {
+ state.Registers[RegisterName.EAX] = state.DataSegment[BitMath.BytesToDword(code, 1)];
+ return state;
+ }
+
+ case OpcodeEncoding.rBP:
+ case OpcodeEncoding.rSI:
+ case OpcodeEncoding.rSP:
+ case OpcodeEncoding.rAX:
+ case OpcodeEncoding.rBX:
+ case OpcodeEncoding.rCX:
+ case OpcodeEncoding.rDX:
+ case OpcodeEncoding.Iz:
+ {
+ switch (opcode.GetStackEffect(code))
+ {
+ case StackEffect.Pop:
+ {
+ destinationRegister = opcode.GetDestinationRegister(code);
+ state.Registers[destinationRegister] = state.Registers[RegisterName.ESP].PointsTo[0];
+ state = state.DoOperation(RegisterName.ESP, OperatorEffect.Sub, new AbstractValue(1));
+ break;
+ }
+ case StackEffect.Push:
+ {
+ state = state.DoOperation(RegisterName.ESP, OperatorEffect.Add, new AbstractValue(1));
+
+ if (opcode.HasSourceRegister(code))
+ {
+ sourceRegister = opcode.GetSourceRegister(code);
+ sourceValue = state.Registers[sourceRegister];
+ }
+ else if (opcode.HasImmediate(code))
+ {
+ sourceValue = new AbstractValue(opcode.GetImmediate(code));
+ }
+ else
+ {
+ throw new InvalidOperationException(String.Format("tried to push something that wasn't a register or an immediate @ 0x{0:x8}", state.InstructionPointer));
+ }
+
+ state.Registers[RegisterName.ESP].PointsTo[0] = sourceValue;
+
+ // TODO(matt_hargett): next step in correct stack emulation,, but breaks PushESPPopESP test
+ // state = state.PushOntoStack(sourceValue);
+
+ break;
+ }
+ }
+
+ return state;
+ }
+
+ case OpcodeEncoding.EvIz:
+ case OpcodeEncoding.EvIb:
+ case OpcodeEncoding.EbIb:
+ case OpcodeEncoding.EvGv:
+ case OpcodeEncoding.EbGb:
+ {
+ destinationRegister = opcode.GetDestinationRegister(code);
+ index = 0;
+
+ if (ModRM.HasIndex(code))
+ {
+ index = ModRM.GetIndex(code);
+ }
+
+ if (opcode.HasImmediate(code))
+ {
+ sourceValue = new AbstractValue(opcode.GetImmediate(code));
+ }
+ else
+ {
+ sourceRegister = ModRM.GetGv(code);
+ sourceValue = state.Registers[sourceRegister];
+ }
+
+ //if (ModRM.HasOffset(code))
+ //{
+ // UInt32 offset = ModRM.GetOffset(code);
+ // state.DataSegment[offset] = sourceValue;
+ // return state;
+ //}
+
+ if (ModRM.IsEffectiveAddressDereferenced(code))
+ {
+ if (!state.Registers[destinationRegister].IsPointer)
+ {
+ throw new InvalidOperationException(
+ "Trying to dereference non-pointer in register " + destinationRegister
+ );
+ }
+
+ state = state.DoOperation(destinationRegister, index, op, sourceValue);
+ if (state.Registers[destinationRegister].PointsTo[index].IsOOB)
+ {
+ reportItems.Add(new ReportItem(state.InstructionPointer, sourceValue.IsTainted));
+ }
+ }
+ else
+ {
+ state = state.DoOperation(destinationRegister, op, sourceValue);
+ if (state.Registers[destinationRegister].IsOOB)
+ {
+ reportItems.Add(new ReportItem(state.InstructionPointer, sourceValue.IsTainted));
+ }
+ }
+
+ return state;
+ }
+
+ case OpcodeEncoding.GvEv:
+ case OpcodeEncoding.GvEb:
+ {
+ sourceRegister = ModRM.GetEv(code);
+ destinationRegister = ModRM.GetGv(code);
+ sourceValue = state.Registers[sourceRegister];
+
+ if (ModRM.HasOffset(code))
+ {
+ UInt32 offset = ModRM.GetOffset(code);
+ sourceValue = state.DataSegment[offset];
+ }
+ else if (ModRM.IsEffectiveAddressDereferenced(code))
+ {
+ if (!sourceValue.IsPointer)
+ {
+ throw new InvalidOperationException(String.Format("Trying to dereference null pointer in register {0}.", sourceRegister));
+ }
+
+ index = 0;
+
+ if (ModRM.HasIndex(code))
+ index = ModRM.GetIndex(code);
+
+ sourceValue = sourceValue.PointsTo[index];
+ if (sourceValue.IsOOB)
+ {
+ reportItems.Add(new ReportItem(state.InstructionPointer, sourceValue.IsTainted));
+ }
+ }
+
+ state = state.DoOperation(destinationRegister, op, sourceValue);
+ return state;
+ }
+
+ case OpcodeEncoding.GvM:
+ {
+ // GvM, M may refer to [base register + offset]
+ if (!ModRM.IsEffectiveAddressDereferenced(code))
+ {
+ throw new InvalidOperationException("GvM must be dereferenced");
+ }
+
+ destinationRegister = opcode.GetDestinationRegister(code);
+ AbstractValue baseRegisterValue;
+ index = 0;
+
+ // TODO: handle the [dword] special case
+ if (ModRM.HasSIB(code))
+ {
+ UInt32 scaledRegisterValue = state.Registers[SIB.GetScaledRegister(code)].Value;
+ UInt32 scaler = SIB.GetScaler(code);
+ baseRegisterValue = state.Registers[SIB.GetBaseRegister(code)];
+ index = (Int32)(scaledRegisterValue * scaler);
+ }
+ else
+ {
+ sourceRegister = ModRM.GetEv(code);
+ if (ModRM.HasIndex(code))
+ {
+ index = ModRM.GetIndex(code);
+ }
+
+ baseRegisterValue = state.Registers[sourceRegister];
+ }
+
+ // TODO: review these casts of index for possible elimination
+ sourceValue = new AbstractValue(
+ baseRegisterValue.PointsTo.DoOperation(
+ OperatorEffect.Add,
+ new AbstractValue((UInt32)index)
+ )
+ );
+
+ state = state.DoOperation(destinationRegister, OperatorEffect.Assignment, sourceValue);
+ if (state.Registers[destinationRegister].IsOOB)
+ {
+ ReportItem reportItem = new ReportItem(state.InstructionPointer, sourceValue.IsTainted);
+ reportItems.Add(reportItem);
+ }
+
+ return state;
+ }
+
+ case OpcodeEncoding.ObAL:
+ {
+ UInt32 offset;
+
+ AbstractValue dwordValue = state.Registers[RegisterName.EAX];
+ AbstractValue byteValue = dwordValue.TruncateValueToByte();
+
+ offset = BitMath.BytesToDword(code, 1); // This is 1 for ObAL
+
+ if (!state.DataSegment.ContainsKey(offset))
+ {
+ state.DataSegment[offset] = new AbstractValue();
+ }
+
+ state = state.DoOperation(offset, op, byteValue);
+ return state;
+ }
+
+ case OpcodeEncoding.Jz:
+ {
+ //TODO: should push EIP + code.Length onto stack
+ Boolean contractSatisfied = false;
+ MallocContract mallocContract = new MallocContract();
+ GLibcStartMainContract glibcStartMainContract = new GLibcStartMainContract();
+ List<Contract> contracts = new List<Contract>();
+ contracts.Add(mallocContract);
+ contracts.Add(glibcStartMainContract);
+
+ foreach (Contract contract in contracts)
+ {
+ if (contract.IsSatisfiedBy(state, code))
+ {
+ contractSatisfied = true;
+ state = contract.Execute(state);
+ }
+ }
+
+ if ( !contractSatisfied )
+ {
+ UInt32 returnAddress = state.InstructionPointer + (UInt32)code.Length;
+ state = state.PushOntoStack(new AbstractValue(returnAddress));
+ state.InstructionPointer = opcode.GetEffectiveAddress(code, state.InstructionPointer);
+ }
+
+ return state;
+ }
+
+ case OpcodeEncoding.Jb:
+ {
+ UInt32 offset;
+ offset = code[1];
+
+ state = state.DoOperation(op, new AbstractValue(offset));
+ state.InstructionPointer += opcode.GetInstructionLength(code);
+
+ return state;
+ }
+
+ case OpcodeEncoding.None:
+ {
+ return state;
+ }
+
+ default:
+ {
+ throw new InvalidOpcodeException(code);
+ }
+ }
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dm...@us...> - 2009-01-05 02:23:25
|
Revision: 160
http://bugreport.svn.sourceforge.net/bugreport/?rev=160&view=rev
Author: dmoniz
Date: 2009-01-05 02:23:20 +0000 (Mon, 05 Jan 2009)
Log Message:
-----------
Gardening: fixing .csproj files to point to newly renamed files, performing stupid fix to standardize X86Emulator.cs from X86emulator.cs due to Subversion limitations.
Modified Paths:
--------------
AnalysisEngine.csproj
TextUI.csproj
Added Paths:
-----------
MainTest.cs
Removed Paths:
-------------
MainTests.cs
X86emulator.cs
Modified: AnalysisEngine.csproj
===================================================================
--- AnalysisEngine.csproj 2009-01-05 02:07:15 UTC (rev 159)
+++ AnalysisEngine.csproj 2009-01-05 02:23:20 UTC (rev 160)
@@ -55,34 +55,35 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AbstractBuffer.cs" />
- <Compile Include="AbstractBufferTests.cs" />
+ <Compile Include="AbstractBufferTest.cs" />
<Compile Include="AbstractValue.cs" />
- <Compile Include="AbstractValueTests.cs" />
+ <Compile Include="AbstractValueTest.cs" />
<Compile Include="Analyzer.cs" />
- <Compile Include="AnalyzerTests.cs" />
+ <Compile Include="AnalyzerTest.cs" />
<Compile Include="ArmEmulator.cs" />
<Compile Include="ArmEmulatorTest.cs" />
<Compile Include="ArmOpcode.cs" />
<Compile Include="ArmOpcodeTest.cs" />
+ <Compile Include="BitMathTest.cs" />
<Compile Include="Contract.cs" />
<Compile Include="CoverageExcludeAttribute.cs" />
+ <Compile Include="DumpFileParserTest.cs" />
<Compile Include="ElfFileParser.cs" />
- <Compile Include="ElfFileParserTests.cs" />
+ <Compile Include="ElfFileParserTest.cs" />
<Compile Include="GLibcStartMainContract.cs" />
<Compile Include="GLibcStartMainContractTest.cs" />
+ <Compile Include="MachineStateTest.cs" />
<Compile Include="MallocContract.cs" />
+ <Compile Include="ModRMTest.cs" />
<Compile Include="Options.cs" />
<Compile Include="OptionsTest.cs" />
<Compile Include="AssemblyInfo.cs" />
<Compile Include="BitMath.cs" />
- <Compile Include="BitMathTests.cs" />
<Compile Include="DumpFileParser.cs" />
- <Compile Include="DumpFileParserTests.cs" />
<Compile Include="MachineState.cs" />
- <Compile Include="MachineStateTests.cs" />
<Compile Include="ModRM.cs" />
- <Compile Include="ModRMTests.cs" />
<Compile Include="Opcode.cs" />
+ <Compile Include="X86EmulatorTest.cs" />
<Compile Include="X86OpcodeTest.cs" />
<Compile Include="RegisterCollection.cs" />
<Compile Include="RegisterCollectionTest.cs" />
@@ -91,7 +92,6 @@
<Compile Include="SIB.cs" />
<Compile Include="SIBTests.cs" />
<Compile Include="X86emulator.cs" />
- <Compile Include="X86emulatorTests.cs" />
<Compile Include="X86Opcode.cs" />
</ItemGroup>
</Project>
\ No newline at end of file
Added: MainTest.cs
===================================================================
--- MainTest.cs (rev 0)
+++ MainTest.cs 2009-01-05 02:23:20 UTC (rev 160)
@@ -0,0 +1,116 @@
+// This file is part of bugreport.
+// Copyright (c) 2006-2009 The bugreport Developers.
+// See AUTHORS.txt for details.
+// Licensed under the GNU General Public License, Version 3 (GPLv3).
+// See LICENSE.txt for details.
+
+using System;
+using NUnit.Framework;
+using System.IO;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Threading;
+
+namespace bugreport
+{
+ [TestFixture]
+ //[Ignore("long")]
+ [Platform(Exclude="Mono")]
+ public class MainTest
+ {
+ // TODO: This assumes that the test runner is run from the build directory.
+ private String testRoot = Directory.GetCurrentDirectory() + @"/../../tests/simple/heap/";
+ private String testDataFile = Directory.GetCurrentDirectory() + @"/../../systemTestsList.txt";
+
+ private void waitForAnalysisToFinish(Process analysisProcess)
+ {
+ TimeSpan maximumTimeAllowed = TimeSpan.FromSeconds(10);
+ while (!analysisProcess.HasExited && (DateTime.Now - analysisProcess.StartTime < maximumTimeAllowed))
+ {
+ Thread.Sleep(100);
+ }
+ }
+
+ private List<String> getOutputFromAnalysis(Process analysisProcess)
+ {
+ List<String> messages = new List<String>();
+
+ analysisProcess.StandardOutput.ReadLine(); // version string
+ analysisProcess.StandardOutput.ReadLine(); // blank line
+ analysisProcess.StandardOutput.ReadLine(); // file name
+ while (!analysisProcess.StandardOutput.EndOfStream)
+ {
+ messages.Add(analysisProcess.StandardOutput.ReadLine());
+ }
+
+ return messages;
+ }
+
+ private Process getAnalysisProcessForFileName(String fileName)
+ {
+ Process analysisProcess = new Process();
+ analysisProcess.StartInfo.FileName = "bugreport.exe";
+ analysisProcess.StartInfo.Arguments = "\"" + fileName + "\"";
+ analysisProcess.StartInfo.RedirectStandardOutput = true;
+ analysisProcess.StartInfo.UseShellExecute = false;
+ analysisProcess.StartInfo.CreateNoWindow = false;
+
+ return analysisProcess;
+ }
+
+ private List<String> getOutputForFilename(String fileName)
+ {
+ Process analysisProcess = getAnalysisProcessForFileName(fileName);
+ analysisProcess.Start();
+
+ waitForAnalysisToFinish(analysisProcess);
+
+ return getOutputFromAnalysis(analysisProcess);
+ }
+
+ [Test]
+ [Category("long")]
+ public void SystemTest()
+ {
+ String[] testSpecifications = File.ReadAllLines(testDataFile);
+
+ foreach(String testSpecification in testSpecifications)
+ {
+ if (testSpecification.Trim().StartsWith("#") || testSpecification.Trim().Length == 0)
+ {
+ continue;
+ }
+
+ // format: filename.dump[,expectedOutput output]
+ String[] args = testSpecification.Split(',');
+ String fileName = (testRoot + args[0]).Trim();
+ String expectedOutput = args[1].Trim();
+
+ Assert.IsTrue(File.Exists(fileName), fileName + " does not exist. Fix paths in test data?");
+
+ List<String> messages = getOutputForFilename(fileName);
+
+ try
+ {
+ if (String.IsNullOrEmpty(expectedOutput))
+ {
+ Assert.IsEmpty(messages, fileName + " ==> not empty: " + messages);
+ }
+ else
+ {
+ StringAssert.Contains(expectedOutput, messages[0]);
+ }
+ }
+ catch (AssertionException)
+ {
+ foreach (String line in messages)
+ {
+ Console.WriteLine(line);
+ }
+
+ throw;
+ }
+ }
+ }
+ }
+}
Deleted: MainTests.cs
===================================================================
--- MainTests.cs 2009-01-05 02:07:15 UTC (rev 159)
+++ MainTests.cs 2009-01-05 02:23:20 UTC (rev 160)
@@ -1,116 +0,0 @@
-// This file is part of bugreport.
-// Copyright (c) 2006-2009 The bugreport Developers.
-// See AUTHORS.txt for details.
-// Licensed under the GNU General Public License, Version 3 (GPLv3).
-// See LICENSE.txt for details.
-
-using System;
-using NUnit.Framework;
-using System.IO;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Threading;
-
-namespace bugreport
-{
- [TestFixture]
- //[Ignore("long")]
- [Platform(Exclude="Mono")]
- public class MainTests
- {
- // TODO: This assumes that the test runner is run from the build directory.
- private String testRoot = Directory.GetCurrentDirectory() + @"/../../tests/simple/heap/";
- private String testDataFile = Directory.GetCurrentDirectory() + @"/../../systemTestsList.txt";
-
- private void waitForAnalysisToFinish(Process analysisProcess)
- {
- TimeSpan maximumTimeAllowed = TimeSpan.FromSeconds(10);
- while (!analysisProcess.HasExited && (DateTime.Now - analysisProcess.StartTime < maximumTimeAllowed))
- {
- Thread.Sleep(100);
- }
- }
-
- private List<String> getOutputFromAnalysis(Process analysisProcess)
- {
- List<String> messages = new List<String>();
-
- analysisProcess.StandardOutput.ReadLine(); // version string
- analysisProcess.StandardOutput.ReadLine(); // blank line
- analysisProcess.StandardOutput.ReadLine(); // file name
- while (!analysisProcess.StandardOutput.EndOfStream)
- {
- messages.Add(analysisProcess.StandardOutput.ReadLine());
- }
-
- return messages;
- }
-
- private Process getAnalysisProcessForFileName(String fileName)
- {
- Process analysisProcess = new Process();
- analysisProcess.StartInfo.FileName = "bugreport.exe";
- analysisProcess.StartInfo.Arguments = "\"" + fileName + "\"";
- analysisProcess.StartInfo.RedirectStandardOutput = true;
- analysisProcess.StartInfo.UseShellExecute = false;
- analysisProcess.StartInfo.CreateNoWindow = false;
-
- return analysisProcess;
- }
-
- private List<String> getOutputForFilename(String fileName)
- {
- Process analysisProcess = getAnalysisProcessForFileName(fileName);
- analysisProcess.Start();
-
- waitForAnalysisToFinish(analysisProcess);
-
- return getOutputFromAnalysis(analysisProcess);
- }
-
- [Test]
- [Category("long")]
- public void SystemTest()
- {
- String[] testSpecifications = File.ReadAllLines(testDataFile);
-
- foreach(String testSpecification in testSpecifications)
- {
- if (testSpecification.Trim().StartsWith("#") || testSpecification.Trim().Length == 0)
- {
- continue;
- }
-
- // format: filename.dump[,expectedOutput output]
- String[] args = testSpecification.Split(',');
- String fileName = (testRoot + args[0]).Trim();
- String expectedOutput = args[1].Trim();
-
- Assert.IsTrue(File.Exists(fileName), fileName + " does not exist. Fix paths in test data?");
-
- List<String> messages = getOutputForFilename(fileName);
-
- try
- {
- if (String.IsNullOrEmpty(expectedOutput))
- {
- Assert.IsEmpty(messages, fileName + " ==> not empty: " + messages);
- }
- else
- {
- StringAssert.Contains(expectedOutput, messages[0]);
- }
- }
- catch (AssertionException)
- {
- foreach (String line in messages)
- {
- Console.WriteLine(line);
- }
-
- throw;
- }
- }
- }
- }
-}
Modified: TextUI.csproj
===================================================================
--- TextUI.csproj 2009-01-05 02:07:15 UTC (rev 159)
+++ TextUI.csproj 2009-01-05 02:23:20 UTC (rev 160)
@@ -58,9 +58,9 @@
<Compile Include="DebuggerView.cs" />
<Compile Include="DebuggerCommandTest.cs" />
<Compile Include="Main.cs" />
- <Compile Include="MainTests.cs" />
+ <Compile Include="MainTest.cs" />
<Compile Include="OpcodeFormatter.cs" />
- <Compile Include="OpcodeFormatterTests.cs" />
+ <Compile Include="OpcodeFormatterTest.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="AnalysisEngine.csproj">
Deleted: X86emulator.cs
===================================================================
--- X86emulator.cs 2009-01-05 02:07:15 UTC (rev 159)
+++ X86emulator.cs 2009-01-05 02:23:20 UTC (rev 160)
@@ -1,347 +0,0 @@
-// This file is part of bugreport.
-// Copyright (c) 2006-2009 The bugreport Developers.
-// See AUTHORS.txt for details.
-// Licensed under the GNU General Public License, Version 3 (GPLv3).
-// See LICENSE.txt for details.
-
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Text;
-
-namespace bugreport
-{
- public class InvalidOpcodeException : Exception
- {
- public InvalidOpcodeException(params Byte[] code)
- : base(FormatOpcodes(code))
- {
- }
-
- public static String FormatOpcodes(params Byte[] code)
- {
- StringBuilder message = new StringBuilder("Invalid opcode: ");
-
-
- foreach (Byte opcode in code)
- {
- message.Append(String.Format(" 0x{0:x2}", opcode));
- }
-
- return message.ToString();
- }
- }
-
- public static class X86Emulator
- {
- private static readonly Opcode opcode = new X86Opcode();
-
- public static MachineState Run(Collection<ReportItem> reportItemCollector, MachineState machineState, Byte[] code)
- {
- if (code.Length == 0)
- {
- throw new ArgumentException("Empty array not allowed.", "code");
- }
-
- MachineState afterState = emulateOpcode(reportItemCollector, machineState, code);
-
- if (!branchTaken(machineState, afterState))
- {
- afterState.InstructionPointer += opcode.GetInstructionLength(code);
- }
- return afterState;
- }
-
- private static Boolean branchTaken(MachineState before, MachineState after)
- {
- return before.InstructionPointer != after.InstructionPointer;
- }
-
- private static MachineState emulateOpcode(ICollection<ReportItem> reportItems, MachineState machineState, Byte[] code)
- {
- MachineState state = machineState;
- RegisterName sourceRegister, destinationRegister;
- AbstractValue sourceValue;
- Int32 index;
-
- OpcodeEncoding encoding = opcode.GetEncoding(code);
- OperatorEffect op = opcode.GetOperatorEffect(code);
-
- switch (encoding)
- {
- case OpcodeEncoding.rAxIv:
- case OpcodeEncoding.rAxIz:
- {
- destinationRegister = opcode.GetDestinationRegister(code);
- UInt32 immediate = opcode.GetImmediate(code);
- state = state.DoOperation(destinationRegister, op, new AbstractValue(immediate));
- return state;
- }
-
- case OpcodeEncoding.rAxOv:
- {
- state.Registers[RegisterName.EAX] = state.DataSegment[BitMath.BytesToDword(code, 1)];
- return state;
- }
-
- case OpcodeEncoding.rBP:
- case OpcodeEncoding.rSI:
- case OpcodeEncoding.rSP:
- case OpcodeEncoding.rAX:
- case OpcodeEncoding.rBX:
- case OpcodeEncoding.rCX:
- case OpcodeEncoding.rDX:
- case OpcodeEncoding.Iz:
- {
- switch (opcode.GetStackEffect(code))
- {
- case StackEffect.Pop:
- {
- destinationRegister = opcode.GetDestinationRegister(code);
- state.Registers[destinationRegister] = state.Registers[RegisterName.ESP].PointsTo[0];
- state = state.DoOperation(RegisterName.ESP, OperatorEffect.Sub, new AbstractValue(1));
- break;
- }
- case StackEffect.Push:
- {
- state = state.DoOperation(RegisterName.ESP, OperatorEffect.Add, new AbstractValue(1));
-
- if (opcode.HasSourceRegister(code))
- {
- sourceRegister = opcode.GetSourceRegister(code);
- sourceValue = state.Registers[sourceRegister];
- }
- else if (opcode.HasImmediate(code))
- {
- sourceValue = new AbstractValue(opcode.GetImmediate(code));
- }
- else
- {
- throw new InvalidOperationException(String.Format("tried to push something that wasn't a register or an immediate @ 0x{0:x8}", state.InstructionPointer));
- }
-
- state.Registers[RegisterName.ESP].PointsTo[0] = sourceValue;
-
- // TODO(matt_hargett): next step in correct stack emulation,, but breaks PushESPPopESP test
- // state = state.PushOntoStack(sourceValue);
-
- break;
- }
- }
-
- return state;
- }
-
- case OpcodeEncoding.EvIz:
- case OpcodeEncoding.EvIb:
- case OpcodeEncoding.EbIb:
- case OpcodeEncoding.EvGv:
- case OpcodeEncoding.EbGb:
- {
- destinationRegister = opcode.GetDestinationRegister(code);
- index = 0;
-
- if (ModRM.HasIndex(code))
- {
- index = ModRM.GetIndex(code);
- }
-
- if (opcode.HasImmediate(code))
- {
- sourceValue = new AbstractValue(opcode.GetImmediate(code));
- }
- else
- {
- sourceRegister = ModRM.GetGv(code);
- sourceValue = state.Registers[sourceRegister];
- }
-
- //if (ModRM.HasOffset(code))
- //{
- // UInt32 offset = ModRM.GetOffset(code);
- // state.DataSegment[offset] = sourceValue;
- // return state;
- //}
-
- if (ModRM.IsEffectiveAddressDereferenced(code))
- {
- if (!state.Registers[destinationRegister].IsPointer)
- {
- throw new InvalidOperationException(
- "Trying to dereference non-pointer in register " + destinationRegister
- );
- }
-
- state = state.DoOperation(destinationRegister, index, op, sourceValue);
- if (state.Registers[destinationRegister].PointsTo[index].IsOOB)
- {
- reportItems.Add(new ReportItem(state.InstructionPointer, sourceValue.IsTainted));
- }
- }
- else
- {
- state = state.DoOperation(destinationRegister, op, sourceValue);
- if (state.Registers[destinationRegister].IsOOB)
- {
- reportItems.Add(new ReportItem(state.InstructionPointer, sourceValue.IsTainted));
- }
- }
-
- return state;
- }
-
- case OpcodeEncoding.GvEv:
- case OpcodeEncoding.GvEb:
- {
- sourceRegister = ModRM.GetEv(code);
- destinationRegister = ModRM.GetGv(code);
- sourceValue = state.Registers[sourceRegister];
-
- if (ModRM.HasOffset(code))
- {
- UInt32 offset = ModRM.GetOffset(code);
- sourceValue = state.DataSegment[offset];
- }
- else if (ModRM.IsEffectiveAddressDereferenced(code))
- {
- if (!sourceValue.IsPointer)
- {
- throw new InvalidOperationException(String.Format("Trying to dereference null pointer in register {0}.", sourceRegister));
- }
-
- index = 0;
-
- if (ModRM.HasIndex(code))
- index = ModRM.GetIndex(code);
-
- sourceValue = sourceValue.PointsTo[index];
- if (sourceValue.IsOOB)
- {
- reportItems.Add(new ReportItem(state.InstructionPointer, sourceValue.IsTainted));
- }
- }
-
- state = state.DoOperation(destinationRegister, op, sourceValue);
- return state;
- }
-
- case OpcodeEncoding.GvM:
- {
- // GvM, M may refer to [base register + offset]
- if (!ModRM.IsEffectiveAddressDereferenced(code))
- {
- throw new InvalidOperationException("GvM must be dereferenced");
- }
-
- destinationRegister = opcode.GetDestinationRegister(code);
- AbstractValue baseRegisterValue;
- index = 0;
-
- // TODO: handle the [dword] special case
- if (ModRM.HasSIB(code))
- {
- UInt32 scaledRegisterValue = state.Registers[SIB.GetScaledRegister(code)].Value;
- UInt32 scaler = SIB.GetScaler(code);
- baseRegisterValue = state.Registers[SIB.GetBaseRegister(code)];
- index = (Int32)(scaledRegisterValue * scaler);
- }
- else
- {
- sourceRegister = ModRM.GetEv(code);
- if (ModRM.HasIndex(code))
- {
- index = ModRM.GetIndex(code);
- }
-
- baseRegisterValue = state.Registers[sourceRegister];
- }
-
- // TODO: review these casts of index for possible elimination
- sourceValue = new AbstractValue(
- baseRegisterValue.PointsTo.DoOperation(
- OperatorEffect.Add,
- new AbstractValue((UInt32)index)
- )
- );
-
- state = state.DoOperation(destinationRegister, OperatorEffect.Assignment, sourceValue);
- if (state.Registers[destinationRegister].IsOOB)
- {
- ReportItem reportItem = new ReportItem(state.InstructionPointer, sourceValue.IsTainted);
- reportItems.Add(reportItem);
- }
-
- return state;
- }
-
- case OpcodeEncoding.ObAL:
- {
- UInt32 offset;
-
- AbstractValue dwordValue = state.Registers[RegisterName.EAX];
- AbstractValue byteValue = dwordValue.TruncateValueToByte();
-
- offset = BitMath.BytesToDword(code, 1); // This is 1 for ObAL
-
- if (!state.DataSegment.ContainsKey(offset))
- {
- state.DataSegment[offset] = new AbstractValue();
- }
-
- state = state.DoOperation(offset, op, byteValue);
- return state;
- }
-
- case OpcodeEncoding.Jz:
- {
- //TODO: should push EIP + code.Length onto stack
- Boolean contractSatisfied = false;
- MallocContract mallocContract = new MallocContract();
- GLibcStartMainContract glibcStartMainContract = new GLibcStartMainContract();
- List<Contract> contracts = new List<Contract>();
- contracts.Add(mallocContract);
- contracts.Add(glibcStartMainContract);
-
- foreach (Contract contract in contracts)
- {
- if (contract.IsSatisfiedBy(state, code))
- {
- contractSatisfied = true;
- state = contract.Execute(state);
- }
- }
-
- if ( !contractSatisfied )
- {
- UInt32 returnAddress = state.InstructionPointer + (UInt32)code.Length;
- state = state.PushOntoStack(new AbstractValue(returnAddress));
- state.InstructionPointer = opcode.GetEffectiveAddress(code, state.InstructionPointer);
- }
-
- return state;
- }
-
- case OpcodeEncoding.Jb:
- {
- UInt32 offset;
- offset = code[1];
-
- state = state.DoOperation(op, new AbstractValue(offset));
- state.InstructionPointer += opcode.GetInstructionLength(code);
-
- return state;
- }
-
- case OpcodeEncoding.None:
- {
- return state;
- }
-
- default:
- {
- throw new InvalidOpcodeException(code);
- }
- }
- }
- }
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dm...@us...> - 2009-01-05 02:07:21
|
Revision: 159
http://bugreport.svn.sourceforge.net/bugreport/?rev=159&view=rev
Author: dmoniz
Date: 2009-01-05 02:07:15 +0000 (Mon, 05 Jan 2009)
Log Message:
-----------
Gardening: updated copyright date to 2009, moved list of contributors to AUTHORS.txt, revised standard file header to point to AUTHORS.txt, changed standard file header to reflect GPLv3 (final), full text of GPLv3 in LICENSE.txt, standardized class and file names of test files to be in the format "FooTest" instead of "FooTests" (we had both mixed and matched), fixed minor coding style issues, fixed line endings of a few files to match the standard (Unix (LF)), updated lib/nunit to contain contents of the bin directory of the NUnit 2.4.8 .NET 2.0 ZIP file distribution. Hopefully not totally broken in Subversion after this commit.
Modified Paths:
--------------
AbstractBuffer.cs
AbstractValue.cs
AnalysisEngine.csproj
Analyzer.cs
AssemblyInfo.cs
BitMath.cs
Contract.cs
CoverageExcludeAttribute.cs
DebuggerCommand.cs
DebuggerCommandTest.cs
DebuggerView.cs
DumpFileParser.cs
ElfFileParser.cs
GLibcStartMainContract.cs
GLibcStartMainContractTest.cs
LICENSE.txt
MachineState.cs
Main.cs
MainTests.cs
MallocContract.cs
ModRM.cs
Opcode.cs
OpcodeFormatter.cs
Options.cs
OptionsTest.cs
RegisterCollection.cs
RegisterCollectionTest.cs
ReportItem.cs
ReportItemTest.cs
SIB.cs
SIBTests.cs
TODO.txt
X86Opcode.cs
X86OpcodeTest.cs
X86emulator.cs
lib/nunit/NUnitFitTests.html
lib/nunit/NUnitTests.config
lib/nunit/NUnitTests.nunit
lib/nunit/mock-assembly.dll
lib/nunit/nonamespace-assembly.dll
lib/nunit/notestfixtures-assembly.dll
lib/nunit/nunit-console-runner.dll
lib/nunit/nunit-console.exe
lib/nunit/nunit-console.exe.config
lib/nunit/nunit-console.tests.dll
lib/nunit/nunit-gui-runner.dll
lib/nunit/nunit-gui.tests.dll
lib/nunit/nunit.core.dll
lib/nunit/nunit.core.extensions.dll
lib/nunit/nunit.core.interfaces.dll
lib/nunit/nunit.core.tests.dll
lib/nunit/nunit.exe
lib/nunit/nunit.exe.config
lib/nunit/nunit.extensions.tests.dll
lib/nunit/nunit.fixtures.dll
lib/nunit/nunit.fixtures.tests.dll
lib/nunit/nunit.framework.dll
lib/nunit/nunit.framework.extensions.dll
lib/nunit/nunit.framework.tests.dll
lib/nunit/nunit.framework.xml
lib/nunit/nunit.mocks.dll
lib/nunit/nunit.mocks.tests.dll
lib/nunit/nunit.uikit.dll
lib/nunit/nunit.uikit.tests.dll
lib/nunit/nunit.util.dll
lib/nunit/nunit.util.tests.dll
lib/nunit/test-assembly.dll
lib/nunit/test-utilities.dll
lib/nunit/timing-tests.dll
Added Paths:
-----------
AUTHORS.txt
AbstractBufferTest.cs
AbstractValueTest.cs
AnalyzerTest.cs
ArmEmulator.cs
ArmEmulatorTest.cs
ArmOpcode.cs
ArmOpcodeTest.cs
BitMathTest.cs
DumpFileParserTest.cs
ElfFileParserTest.cs
HEADER.txt
MachineStateTest.cs
ModRMTest.cs
OpcodeFormatterTest.cs
X86EmulatorTest.cs
lib/nunit/loadtest-assembly.dll
lib/nunit/nunit-console-x86.exe
lib/nunit/nunit-console-x86.exe.config
lib/nunit/nunit-x86.exe
lib/nunit/nunit-x86.exe.config
Removed Paths:
-------------
AbstractBufferTests.cs
AbstractValueTests.cs
AnalyzerTests.cs
BitMathTests.cs
DumpFileParserTests.cs
ElfFileParserTests.cs
MachineStateTests.cs
ModRMTests.cs
OpcodeFormatterTests.cs
X86emulatorTests.cs
lib/nunit/TestResult.xml
lib/nunit/bin/
lib/nunit/mock-assembly.dll.config
lib/nunit/nunit-console.tests.dll.config
lib/nunit/nunit-gui.exe
lib/nunit/nunit-gui.exe.config
lib/nunit/nunit-gui.tests.dll.config
lib/nunit/nunit-test-server.dll
lib/nunit/nunit.common.dll
lib/nunit/nunit.core.tests.dll.config
lib/nunit/nunit.extensions.tests.dll.config
lib/nunit/nunit.framework.tests.dll.config
lib/nunit/nunit.mocks.tests.dll.config
lib/nunit/nunit.uikit.tests.dll.config
lib/nunit/nunit.util.tests.dll.config
Property Changed:
----------------
/
Property changes on:
___________________________________________________________________
Modified: svn:ignore
- bugreport.vtg
bugreport.vpwhist
bugreport.vpw
bugreport.vpj
+ bugreport.vtg
bugreport.vpwhist
bugreport.vpw
bugreport.vpj
*.user
Added: AUTHORS.txt
===================================================================
--- AUTHORS.txt (rev 0)
+++ AUTHORS.txt 2009-01-05 02:07:15 UTC (rev 159)
@@ -0,0 +1,13 @@
+bugreport is copyright (c) 2006-2009 The bugreport Developers.
+
+The bugreport Developers are:
+
+Luis Miras
+Doug Coker
+Todd Nagengast
+Anthony Lineberry
+Dan Moniz
+Bryan Siepert
+Mike Seery
+Cullen Bryan
+Matt Hargett
Modified: AbstractBuffer.cs
===================================================================
--- AbstractBuffer.cs 2008-09-11 02:15:48 UTC (rev 158)
+++ AbstractBuffer.cs 2009-01-05 02:07:15 UTC (rev 159)
@@ -1,150 +1,151 @@
-// Copyright (c) 2006-2008 Luis Miras, Doug Coker, Todd Nagengast,
-// Anthony Lineberry, Dan Moniz, Bryan Siepert, Mike Seery, Cullen Bryan
-// Licensed under GPLv3 draft 3
+// This file is part of bugreport.
+// Copyright (c) 2006-2009 The bugreport Developers.
+// See AUTHORS.txt for details.
+// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
using System;
namespace bugreport
{
-public class AbstractBuffer
-{
- private AbstractValue[] storage;
- private UInt32 baseIndex;
- private readonly Int32 allocatedLength;
-
- public AbstractBuffer(AbstractValue[] _buffer)
+ public class AbstractBuffer
{
- storage = _buffer;
- allocatedLength = storage.Length;
- }
+ private AbstractValue[] storage;
+ private UInt32 baseIndex;
+ private readonly Int32 allocatedLength;
- public AbstractBuffer(AbstractBuffer _copyMe)
- {
- baseIndex = _copyMe.BaseIndex;
- allocatedLength = _copyMe.allocatedLength;
- storage = new AbstractValue[_copyMe.storage.Length];
- Array.Copy(_copyMe.storage, storage, _copyMe.storage.Length);
- }
+ public AbstractBuffer(AbstractValue[] _buffer)
+ {
+ storage = _buffer;
+ allocatedLength = storage.Length;
+ }
- private void extend(UInt32 _newLength)
- {
- // Account for element [0] of the array
- _newLength = _newLength + 1;
- if (_newLength >= Length)
+ public AbstractBuffer(AbstractBuffer _copyMe)
{
- AbstractValue[] _copyTo = new AbstractValue[_newLength];
+ baseIndex = _copyMe.BaseIndex;
+ allocatedLength = _copyMe.allocatedLength;
+ storage = new AbstractValue[_copyMe.storage.Length];
+ Array.Copy(_copyMe.storage, storage, _copyMe.storage.Length);
+ }
- Int32 i;
- for (i = 0; i < storage.Length; i++)
+ private void extend(UInt32 _newLength)
+ {
+ // Account for element [0] of the array
+ _newLength = _newLength + 1;
+ if (_newLength >= Length)
{
- _copyTo[i] = storage[i];
+ AbstractValue[] _copyTo = new AbstractValue[_newLength];
+
+ Int32 i;
+ for (i = 0; i < storage.Length; i++)
+ {
+ _copyTo[i] = storage[i];
+ }
+ for (; i < _newLength; i++)
+ {
+ _copyTo[i] = new AbstractValue(AbstractValue.UNKNOWN);
+ _copyTo[i].IsOOB = true;
+ }
+ storage = _copyTo;
}
- for (; i < _newLength; i++)
- {
- _copyTo[i] = new AbstractValue(AbstractValue.UNKNOWN);
- _copyTo[i].IsOOB = true;
- }
- storage = _copyTo;
+
+ return;
}
- return;
- }
-
- public AbstractBuffer DoOperation(OperatorEffect _operatorEffect, AbstractValue _rhs)
- {
- AbstractBuffer lhs = this;
- // TODO: should have a guard for if _rhs isnt a pointer
- switch (_operatorEffect)
+ public AbstractBuffer DoOperation(OperatorEffect _operatorEffect, AbstractValue _rhs)
{
- case OperatorEffect.Assignment:
+ AbstractBuffer lhs = this;
+ // TODO: should have a guard for if _rhs isnt a pointer
+ switch (_operatorEffect)
{
- AbstractBuffer result = new AbstractBuffer(lhs);
-
- return result;
- }
- case OperatorEffect.Add:
- {
- AbstractBuffer result = new AbstractBuffer(lhs);
- result.baseIndex += _rhs.Value;
-
- return result;
- }
-
- case OperatorEffect.Sub:
- {
- AbstractBuffer result = new AbstractBuffer(lhs);
-
- if (result.baseIndex < _rhs.Value)
+ case OperatorEffect.Assignment:
{
- throw new ArgumentOutOfRangeException(String.Format("Attempting to set a negative baseindex, baseindex: {0:x4}, _subValue {1:x4}", result.baseIndex, _rhs.Value));
+ AbstractBuffer result = new AbstractBuffer(lhs);
+
+ return result;
}
-
- result.baseIndex -= _rhs.Value;
- return result;
+ case OperatorEffect.Add:
+ {
+ AbstractBuffer result = new AbstractBuffer(lhs);
+ result.baseIndex += _rhs.Value;
+
+ return result;
+ }
+
+ case OperatorEffect.Sub:
+ {
+ AbstractBuffer result = new AbstractBuffer(lhs);
+
+ if (result.baseIndex < _rhs.Value)
+ {
+ throw new ArgumentOutOfRangeException(String.Format("Attempting to set a negative baseindex, baseindex: {0:x4}, _subValue {1:x4}", result.baseIndex, _rhs.Value));
+ }
+
+ result.baseIndex -= _rhs.Value;
+ return result;
+ }
+
+ case OperatorEffect.And:
+ {
+ AbstractBuffer result = new AbstractBuffer(lhs);
+
+ result.baseIndex &= _rhs.Value;
+ return result;
+ }
+
+ default:
+ throw new ArgumentException(String.Format("Unsupported OperatorEffect: {0}", _operatorEffect), "_operatorEffect");
}
-
- case OperatorEffect.And:
- {
- AbstractBuffer result = new AbstractBuffer(lhs);
-
- result.baseIndex &= _rhs.Value;
- return result;
- }
-
- default:
- throw new ArgumentException(String.Format("Unsupported OperatorEffect: {0}", _operatorEffect), "_operatorEffect");
}
- }
- private Boolean IsIndexPastBounds(Int32 index)
- {
- return (((baseIndex + index) >= allocatedLength) && ((baseIndex + index) >= storage.Length));
- }
+ private Boolean IsIndexPastBounds(Int32 index)
+ {
+ return (((baseIndex + index) >= allocatedLength) && ((baseIndex + index) >= storage.Length));
+ }
- public AbstractValue this[Int32 index]
- {
- get
+ public AbstractValue this[Int32 index]
{
- // We check this.storage.Length as well so that we aren't calling Extend() when we dont need to.
- if (IsIndexPastBounds(index))
+ get
{
- extend(baseIndex + (UInt32)index);
- return storage[baseIndex + index];
+ // We check this.storage.Length as well so that we aren't calling Extend() when we dont need to.
+ if (IsIndexPastBounds(index))
+ {
+ extend(baseIndex + (UInt32)index);
+ return storage[baseIndex + index];
+ }
+ else
+ {
+ return storage[baseIndex + index];
+ }
}
- else
+
+ set
{
- return storage[baseIndex + index];
+ if ((baseIndex + index) >= allocatedLength)
+ {
+ value.IsOOB = true;
+ }
+
+ if (IsIndexPastBounds(index))
+ {
+ extend(baseIndex + (UInt32)index);
+ storage[baseIndex + index] = value;
+ }
+ else
+ {
+ storage[baseIndex + index] = value;
+ }
}
}
- set
+ public UInt32 BaseIndex
{
- if ((baseIndex + index) >= allocatedLength)
- {
- value.IsOOB = true;
- }
-
- if (IsIndexPastBounds(index))
- {
- extend(baseIndex + (UInt32)index);
- storage[baseIndex + index] = value;
- }
- else
- {
- storage[baseIndex + index] = value;
- }
+ get { return baseIndex; }
}
- }
- public UInt32 BaseIndex
- {
- get { return baseIndex; }
+ public Int32 Length
+ {
+ get { return allocatedLength; }
+ }
}
-
- public Int32 Length
- {
- get { return allocatedLength; }
- }
}
-}
Added: AbstractBufferTest.cs
===================================================================
--- AbstractBufferTest.cs (rev 0)
+++ AbstractBufferTest.cs 2009-01-05 02:07:15 UTC (rev 159)
@@ -0,0 +1,217 @@
+// This file is part of bugreport.
+// Copyright (c) 2006-2009 The bugreport Developers.
+// See AUTHORS.txt for details.
+// Licensed under the GNU General Public License, Version 3 (GPLv3).
+// See LICENSE.txt for details.
+
+using System;
+using NUnit.Framework;
+
+namespace bugreport
+{
+ [TestFixture]
+ public class AbstractBufferTest
+ {
+ [Test]
+ public void PointerAssignment()
+ {
+ AbstractValue[] values = AbstractValue.GetNewBuffer(4);
+ AbstractBuffer buffer = new AbstractBuffer(values);
+ AbstractBuffer assignedBuffer = buffer.DoOperation(OperatorEffect.Assignment, null);
+ Assert.AreNotSame(buffer, assignedBuffer);
+ }
+
+ [Test]
+ public void Copy()
+ {
+ AbstractValue[] values = AbstractValue.GetNewBuffer(4);
+ AbstractBuffer buffer = new AbstractBuffer(values);
+ AbstractBuffer newBuffer = new AbstractBuffer(buffer);
+ Assert.AreNotSame(newBuffer, buffer);
+
+ for (Int32 index=0; index < newBuffer.Length; index++)
+ {
+ Assert.AreSame(newBuffer[index], buffer[index]);
+ }
+ }
+
+ [Test]
+ public void PointerAdd()
+ {
+ AbstractValue one = new AbstractValue(0x1);
+ AbstractValue two = new AbstractValue(0x2);
+ AbstractValue three = new AbstractValue(0x3);
+ AbstractValue four = new AbstractValue(0x4);
+ AbstractValue[] avBuffer = AbstractValue.GetNewBuffer(4);
+
+ avBuffer[0] = one;
+ avBuffer[1] = two;
+ avBuffer[2] = three;
+ avBuffer[3] = four;
+
+ AbstractBuffer buffer = new AbstractBuffer(avBuffer);
+ Assert.AreEqual(one, buffer[0]);
+ AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(2));
+ Assert.AreEqual(three, modifiedBuffer[0]);
+
+ }
+
+ [Test]
+ public void PointerSub()
+ {
+ AbstractValue one = new AbstractValue(0x1);
+ AbstractValue two = new AbstractValue(0x2);
+ AbstractValue three = new AbstractValue(0x3);
+ AbstractValue four = new AbstractValue(0x4);
+ AbstractValue[] avBuffer = AbstractValue.GetNewBuffer(4);
+
+ avBuffer[0] = one;
+ avBuffer[1] = two;
+ avBuffer[2] = three;
+ avBuffer[3] = four;
+
+ AbstractBuffer buffer = new AbstractBuffer(avBuffer);
+ Assert.AreEqual(one, buffer[0]);
+ AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(2));
+ Assert.AreEqual(three, modifiedBuffer[0]);
+
+ AbstractBuffer subbedBuffer = modifiedBuffer.DoOperation(OperatorEffect.Sub, new AbstractValue(2));
+ Assert.AreEqual(one, subbedBuffer[0]);
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentOutOfRangeException))]
+ public void PointerSubUnderflow()
+ {
+ new AbstractBuffer(new AbstractValue[] {}).DoOperation(OperatorEffect.Sub, new AbstractValue(1));
+ }
+
+ [Test]
+ public void PointerAnd()
+ {
+ AbstractValue one = new AbstractValue(0x1);
+ AbstractValue two = new AbstractValue(0x2);
+ AbstractValue three = new AbstractValue(0x3);
+ AbstractValue four = new AbstractValue(0x4);
+ AbstractValue[] avBuffer = AbstractValue.GetNewBuffer(4);
+
+ avBuffer[0] = one;
+ avBuffer[1] = two;
+ avBuffer[2] = three;
+ avBuffer[3] = four;
+
+ AbstractBuffer buffer = new AbstractBuffer(avBuffer);
+ Assert.AreEqual(one, buffer[0]);
+ AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(3));
+ Assert.AreEqual(four, modifiedBuffer[0]);
+ AbstractBuffer andedBuffer = modifiedBuffer.DoOperation(OperatorEffect.And, new AbstractValue(0xfffffff0));
+ Assert.AreEqual(one, andedBuffer[0]);
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentOutOfRangeException))]
+ public void InvalidPointerAnd()
+ {
+ AbstractValue one = new AbstractValue(0x1);
+ AbstractBuffer buffer = new AbstractBuffer(new AbstractValue[] {one});
+ AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Sub, new AbstractValue(3));
+ modifiedBuffer.DoOperation(OperatorEffect.And, new AbstractValue(0xf));
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void PointerUnknownOperation()
+ {
+ new AbstractBuffer(new AbstractValue[] {}).DoOperation(OperatorEffect.Unknown, null);
+ }
+
+
+ [Test]
+ public void PointerOverflowByOne()
+ {
+ AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
+ AbstractBuffer pointer = new AbstractBuffer(buffer);
+
+ AbstractValue value = pointer[16];
+ Assert.IsTrue(value.IsOOB);
+ Assert.IsFalse(value.IsInitialized);
+ Assert.AreEqual(AbstractValue.UNKNOWN, value.Value);
+ }
+
+ [Test]
+ public void PointerOverflowStillRetainsOldValues()
+ {
+ AbstractValue test1 = new AbstractValue(0x41);
+ AbstractValue test2 = new AbstractValue(0x42);
+ AbstractValue[] buffer = AbstractValue.GetNewBuffer(2);
+
+ buffer[0] = test1;
+ buffer[1] = test2;
+
+ AbstractBuffer pointer = new AbstractBuffer(buffer);
+
+ // Accessing pointer[2] will cause the AbstractBuffer to extend..
+ Assert.IsTrue(pointer[2].IsOOB, " value is not out of bounds");
+ Assert.IsFalse(pointer[2].IsInitialized);
+ Assert.AreEqual(AbstractValue.UNKNOWN, pointer[2].Value);
+
+ // And then we make sure the in bounds values stay the same
+ Assert.IsFalse(pointer[0].IsOOB);
+ Assert.IsFalse(pointer[1].IsOOB);
+
+ Assert.AreEqual(0x41, pointer[0].Value);
+ Assert.AreEqual(0x42, pointer[1].Value);
+ }
+
+ [Test]
+ public void PointerOverflowTwiceStillRetainsOriginalValues()
+ {
+ AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
+ AbstractBuffer pointer = new AbstractBuffer(buffer);
+
+ //Access beyond buffer bounds forcing buffer to expand
+ Assert.IsTrue(pointer[17].IsOOB);
+ Assert.IsFalse(pointer[17].IsInitialized);
+ Assert.AreEqual(AbstractValue.UNKNOWN, pointer[17].Value);
+
+ pointer[17] = new AbstractValue(0x41414141);
+
+ // Access beyond previously expanded bounds to force 2nd expand
+ Assert.IsTrue(pointer[64].IsOOB);
+ Assert.IsFalse(pointer[64].IsInitialized);
+ Assert.AreEqual(AbstractValue.UNKNOWN, pointer[64].Value);
+
+ // check that value set outside of bounds is still the same as well
+ Assert.IsTrue(pointer[17].IsOOB);
+ Assert.AreEqual(0x41414141, pointer[17].Value);
+ }
+
+ [Test]
+ public void OverflowDoesntLoseIncrement()
+ {
+ AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
+ AbstractBuffer pointer = new AbstractBuffer(buffer);
+ AbstractValue value = new AbstractValue(0x41);
+ value = value.AddTaint();
+
+ pointer[0] = value;
+
+ pointer = pointer.DoOperation(OperatorEffect.Add, new AbstractValue(1));
+
+ pointer[16] = value;
+
+ pointer = pointer.DoOperation(OperatorEffect.Sub, new AbstractValue(1));
+
+ Assert.AreEqual(0x41, pointer[0].Value);
+ Assert.IsTrue(value.IsTainted);
+ Assert.AreEqual(0x41, pointer[17].Value);
+ Assert.IsTrue(pointer[17].IsTainted);
+ }
+
+ [Test]
+ public void OverflowZeroSizeBuffer() {
+ AbstractBuffer f = new AbstractBuffer(new AbstractValue[] {});
+ Assert.IsFalse(f[0].IsInitialized);
+ }
+ }
+}
Deleted: AbstractBufferTests.cs
===================================================================
--- AbstractBufferTests.cs 2008-09-11 02:15:48 UTC (rev 158)
+++ AbstractBufferTests.cs 2009-01-05 02:07:15 UTC (rev 159)
@@ -1,216 +0,0 @@
-// Copyright (c) 2006-2008 Luis Miras, Doug Coker, Todd Nagengast,
-// Anthony Lineberry, Dan Moniz, Bryan Siepert, Mike Seery, Cullen Bryan
-// Licensed under GPLv3 draft 3
-// See LICENSE.txt for details.
-
-using System;
-using NUnit.Framework;
-
-namespace bugreport
-{
-[TestFixture]
-public class AbstractBufferTests
-{
- [Test]
- public void PointerAssignment()
- {
- AbstractValue[] values = AbstractValue.GetNewBuffer(4);
- AbstractBuffer buffer = new AbstractBuffer(values);
- AbstractBuffer assignedBuffer = buffer.DoOperation(OperatorEffect.Assignment, null);
- Assert.AreNotSame(buffer, assignedBuffer);
- }
-
- [Test]
- public void Copy()
- {
- AbstractValue[] values = AbstractValue.GetNewBuffer(4);
- AbstractBuffer buffer = new AbstractBuffer(values);
- AbstractBuffer newBuffer = new AbstractBuffer(buffer);
- Assert.AreNotSame(newBuffer, buffer);
-
- for (Int32 index=0; index < newBuffer.Length; index++)
- {
- Assert.AreSame(newBuffer[index], buffer[index]);
- }
- }
-
- [Test]
- public void PointerAdd()
- {
- AbstractValue one = new AbstractValue(0x1);
- AbstractValue two = new AbstractValue(0x2);
- AbstractValue three = new AbstractValue(0x3);
- AbstractValue four = new AbstractValue(0x4);
- AbstractValue[] avBuffer = AbstractValue.GetNewBuffer(4);
-
- avBuffer[0] = one;
- avBuffer[1] = two;
- avBuffer[2] = three;
- avBuffer[3] = four;
-
- AbstractBuffer buffer = new AbstractBuffer(avBuffer);
- Assert.AreEqual(one, buffer[0]);
- AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(2));
- Assert.AreEqual(three, modifiedBuffer[0]);
-
- }
-
- [Test]
- public void PointerSub()
- {
- AbstractValue one = new AbstractValue(0x1);
- AbstractValue two = new AbstractValue(0x2);
- AbstractValue three = new AbstractValue(0x3);
- AbstractValue four = new AbstractValue(0x4);
- AbstractValue[] avBuffer = AbstractValue.GetNewBuffer(4);
-
- avBuffer[0] = one;
- avBuffer[1] = two;
- avBuffer[2] = three;
- avBuffer[3] = four;
-
- AbstractBuffer buffer = new AbstractBuffer(avBuffer);
- Assert.AreEqual(one, buffer[0]);
- AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(2));
- Assert.AreEqual(three, modifiedBuffer[0]);
-
- AbstractBuffer subbedBuffer = modifiedBuffer.DoOperation(OperatorEffect.Sub, new AbstractValue(2));
- Assert.AreEqual(one, subbedBuffer[0]);
- }
-
- [Test]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- public void PointerSubUnderflow()
- {
- new AbstractBuffer(new AbstractValue[] {}).DoOperation(OperatorEffect.Sub, new AbstractValue(1));
- }
-
- [Test]
- public void PointerAnd()
- {
- AbstractValue one = new AbstractValue(0x1);
- AbstractValue two = new AbstractValue(0x2);
- AbstractValue three = new AbstractValue(0x3);
- AbstractValue four = new AbstractValue(0x4);
- AbstractValue[] avBuffer = AbstractValue.GetNewBuffer(4);
-
- avBuffer[0] = one;
- avBuffer[1] = two;
- avBuffer[2] = three;
- avBuffer[3] = four;
-
- AbstractBuffer buffer = new AbstractBuffer(avBuffer);
- Assert.AreEqual(one, buffer[0]);
- AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(3));
- Assert.AreEqual(four, modifiedBuffer[0]);
- AbstractBuffer andedBuffer = modifiedBuffer.DoOperation(OperatorEffect.And, new AbstractValue(0xfffffff0));
- Assert.AreEqual(one, andedBuffer[0]);
- }
-
- [Test]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- public void InvalidPointerAnd()
- {
- AbstractValue one = new AbstractValue(0x1);
- AbstractBuffer buffer = new AbstractBuffer(new AbstractValue[] {one});
- AbstractBuffer modifiedBuffer = buffer.DoOperation(OperatorEffect.Sub, new AbstractValue(3));
- modifiedBuffer.DoOperation(OperatorEffect.And, new AbstractValue(0xf));
- }
-
- [Test]
- [ExpectedException(typeof(ArgumentException))]
- public void PointerUnknownOperation()
- {
- new AbstractBuffer(new AbstractValue[] {}).DoOperation(OperatorEffect.Unknown, null);
- }
-
-
- [Test]
- public void PointerOverflowByOne()
- {
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
- AbstractBuffer pointer = new AbstractBuffer(buffer);
-
- AbstractValue value = pointer[16];
- Assert.IsTrue(value.IsOOB);
- Assert.IsFalse(value.IsInitialized);
- Assert.AreEqual(AbstractValue.UNKNOWN, value.Value);
- }
-
- [Test]
- public void PointerOverflowStillRetainsOldValues()
- {
- AbstractValue test1 = new AbstractValue(0x41);
- AbstractValue test2 = new AbstractValue(0x42);
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(2);
-
- buffer[0] = test1;
- buffer[1] = test2;
-
- AbstractBuffer pointer = new AbstractBuffer(buffer);
-
- // Accessing pointer[2] will cause the AbstractBuffer to extend..
- Assert.IsTrue(pointer[2].IsOOB, " value is not out of bounds");
- Assert.IsFalse(pointer[2].IsInitialized);
- Assert.AreEqual(AbstractValue.UNKNOWN, pointer[2].Value);
-
- // And then we make sure the in bounds values stay the same
- Assert.IsFalse(pointer[0].IsOOB);
- Assert.IsFalse(pointer[1].IsOOB);
-
- Assert.AreEqual(0x41, pointer[0].Value);
- Assert.AreEqual(0x42, pointer[1].Value);
- }
-
- [Test]
- public void PointerOverflowTwiceStillRetainsOriginalValues()
- {
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
- AbstractBuffer pointer = new AbstractBuffer(buffer);
-
- //Access beyond buffer bounds forcing buffer to expand
- Assert.IsTrue(pointer[17].IsOOB);
- Assert.IsFalse(pointer[17].IsInitialized);
- Assert.AreEqual(AbstractValue.UNKNOWN, pointer[17].Value);
-
- pointer[17] = new AbstractValue(0x41414141);
-
- // Access beyond previously expanded bounds to force 2nd expand
- Assert.IsTrue(pointer[64].IsOOB);
- Assert.IsFalse(pointer[64].IsInitialized);
- Assert.AreEqual(AbstractValue.UNKNOWN, pointer[64].Value);
-
- // check that value set outside of bounds is still the same as well
- Assert.IsTrue(pointer[17].IsOOB);
- Assert.AreEqual(0x41414141, pointer[17].Value);
- }
-
- [Test]
- public void OverflowDoesntLoseIncrement()
- {
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
- AbstractBuffer pointer = new AbstractBuffer(buffer);
- AbstractValue value = new AbstractValue(0x41);
- value = value.AddTaint();
-
- pointer[0] = value;
-
- pointer = pointer.DoOperation(OperatorEffect.Add, new AbstractValue(1));
-
- pointer[16] = value;
-
- pointer = pointer.DoOperation(OperatorEffect.Sub, new AbstractValue(1));
-
- Assert.AreEqual(0x41, pointer[0].Value);
- Assert.IsTrue(value.IsTainted);
- Assert.AreEqual(0x41, pointer[17].Value);
- Assert.IsTrue(pointer[17].IsTainted);
- }
-
- [Test]
- public void OverflowZeroSizeBuffer() {
- AbstractBuffer f = new AbstractBuffer(new AbstractValue[] {});
- Assert.IsFalse(f[0].IsInitialized);
- }
-}
-}
Modified: AbstractValue.cs
===================================================================
--- AbstractValue.cs 2008-09-11 02:15:48 UTC (rev 158)
+++ AbstractValue.cs 2009-01-05 02:07:15 UTC (rev 159)
@@ -1,6 +1,7 @@
-// Copyright (c) 2006-2008 Luis Miras, Doug Coker, Todd Nagengast,
-// Anthony Lineberry, Dan Moniz, Bryan Siepert, Mike Seery, Cullen Bryan
-// Licensed under GPLv3 draft 3
+// This file is part of bugreport.
+// Copyright (c) 2006-2009 The bugreport Developers.
+// See AUTHORS.txt for details.
+// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
using System;
@@ -8,217 +9,217 @@
namespace bugreport
{
-public class AbstractValue
-{
- AbstractBuffer pointsTo;
- UInt32 storage;
- Boolean tainted;
- Boolean isOOB;
+ public class AbstractValue
+ {
+ AbstractBuffer pointsTo;
+ UInt32 storage;
+ Boolean tainted;
+ Boolean isOOB;
- public const UInt32 UNKNOWN = 0xb4dc0d3d;
- public const UInt32 MAX_BUFFER_SIZE = 25600000;
+ public const UInt32 UNKNOWN = 0xb4dc0d3d;
+ public const UInt32 MAX_BUFFER_SIZE = 25600000;
- public AbstractValue()
- {
- storage = UNKNOWN;
- }
-
- public AbstractValue(AbstractValue[] _willPointTo)
- {
- if (_willPointTo.Length == 0)
+ public AbstractValue()
{
- throw new ArgumentException("Empty buffer is not allowed", "_willPointTo");
+ storage = UNKNOWN;
}
-
- storage = 0xdeadbeef;
- pointsTo = new AbstractBuffer(_willPointTo);
- }
- public AbstractValue(AbstractBuffer _willPointTo)
- {
- if (_willPointTo.Length == 0)
+ public AbstractValue(AbstractValue[] _willPointTo)
{
- throw new ArgumentException("Empty buffer is not allowed", "_willPointTo");
+ if (_willPointTo.Length == 0)
+ {
+ throw new ArgumentException("Empty buffer is not allowed", "_willPointTo");
+ }
+
+ storage = 0xdeadbeef;
+ pointsTo = new AbstractBuffer(_willPointTo);
}
-
- storage = 0xdeadbeef;
- pointsTo = new AbstractBuffer(_willPointTo);
- }
- public AbstractValue(AbstractValue _copyMe)
- {
- if (_copyMe == null)
+ public AbstractValue(AbstractBuffer _willPointTo)
{
- throw new ArgumentNullException("_copyMe");
+ if (_willPointTo.Length == 0)
+ {
+ throw new ArgumentException("Empty buffer is not allowed", "_willPointTo");
+ }
+
+ storage = 0xdeadbeef;
+ pointsTo = new AbstractBuffer(_willPointTo);
}
- storage = _copyMe.Value;
- tainted = _copyMe.IsTainted;
- isOOB = _copyMe.IsOOB;
-
- if (_copyMe.PointsTo != null)
+ public AbstractValue(AbstractValue _copyMe)
{
- pointsTo = new AbstractBuffer(_copyMe.PointsTo);
- }
- }
+ if (_copyMe == null)
+ {
+ throw new ArgumentNullException("_copyMe");
+ }
- public AbstractValue(UInt32 _value)
- {
- storage = _value;
- }
+ storage = _copyMe.Value;
+ tainted = _copyMe.IsTainted;
+ isOOB = _copyMe.IsOOB;
- public override Boolean Equals(object obj)
- {
- AbstractValue other = obj as AbstractValue;
+ if (_copyMe.PointsTo != null)
+ {
+ pointsTo = new AbstractBuffer(_copyMe.PointsTo);
+ }
+ }
- if (null == other)
+ public AbstractValue(UInt32 _value)
{
- return false;
+ storage = _value;
}
- return this.Value == other.Value &&
- this.IsOOB == other.IsOOB &&
- this.IsTainted == other.IsTainted &&
- this.PointsTo == other.PointsTo;
- }
+ public override Boolean Equals(object obj)
+ {
+ AbstractValue other = obj as AbstractValue;
- public override Int32 GetHashCode()
- {
- Int32 hashCode = this.Value.GetHashCode() ^ this.IsOOB.GetHashCode() ^
- this.IsTainted.GetHashCode();
+ if (null == other)
+ {
+ return false;
+ }
- if (this.PointsTo != null)
- {
- hashCode ^= this.PointsTo.GetHashCode();
+ return this.Value == other.Value &&
+ this.IsOOB == other.IsOOB &&
+ this.IsTainted == other.IsTainted &&
+ this.PointsTo == other.PointsTo;
}
- return hashCode;
- }
-
- public static AbstractValue[] GetNewBuffer(UInt32 size)
- {
- if (size > MAX_BUFFER_SIZE)
+ public override Int32 GetHashCode()
{
- throw new ArgumentOutOfRangeException("size", "Size specified larger than maximum allowed: " + MAX_BUFFER_SIZE);
- }
-
- AbstractValue[] buffer = new AbstractValue[size];
- for (UInt32 i = 0; i < size; i++)
- {
- buffer[i] = new AbstractValue();
- }
-
- return buffer;
- }
+ Int32 hashCode = this.Value.GetHashCode() ^ this.IsOOB.GetHashCode() ^
+ this.IsTainted.GetHashCode();
- public AbstractValue TruncateValueToByte()
- {
- UInt32 byteValue = this.Value & 0xff;
- AbstractValue truncatedValue = new AbstractValue(byteValue);
- truncatedValue.IsTainted = this.IsTainted;
+ if (this.PointsTo != null)
+ {
+ hashCode ^= this.PointsTo.GetHashCode();
+ }
- return truncatedValue;
- }
+ return hashCode;
+ }
- public AbstractValue AddTaint()
- {
- if (this.PointsTo != null)
+ public static AbstractValue[] GetNewBuffer(UInt32 size)
{
- throw new InvalidOperationException("Cannot AddTaint to a pointer");
+ if (size > MAX_BUFFER_SIZE)
+ {
+ throw new ArgumentOutOfRangeException("size", "Size specified larger than maximum allowed: " + MAX_BUFFER_SIZE);
+ }
+
+ AbstractValue[] buffer = new AbstractValue[size];
+ for (UInt32 i = 0; i < size; i++)
+ {
+ buffer[i] = new AbstractValue();
+ }
+
+ return buffer;
}
- AbstractValue taintedValue = new AbstractValue(this);
- taintedValue.IsTainted = true;
- return taintedValue;
- }
+ public AbstractValue TruncateValueToByte()
+ {
+ UInt32 byteValue = this.Value & 0xff;
+ AbstractValue truncatedValue = new AbstractValue(byteValue);
+ truncatedValue.IsTainted = this.IsTainted;
- public AbstractValue AddTaintIf(Boolean condition)
- {
- if (condition)
- {
- return AddTaint();
+ return truncatedValue;
}
- return this;
- }
+ public AbstractValue AddTaint()
+ {
+ if (this.PointsTo != null)
+ {
+ throw new InvalidOperationException("Cannot AddTaint to a pointer");
+ }
- public AbstractBuffer PointsTo
- {
- get { return pointsTo; }
- }
+ AbstractValue taintedValue = new AbstractValue(this);
+ taintedValue.IsTainted = true;
+ return taintedValue;
+ }
- public Boolean IsTainted
- {
- get { return tainted; }
+ public AbstractValue AddTaintIf(Boolean condition)
+ {
+ if (condition)
+ {
+ return AddTaint();
+ }
- private set { tainted = value; }
- }
+ return this;
+ }
- public Boolean IsOOB
- {
- get { return isOOB; }
- set { isOOB = value; }
- }
+ public AbstractBuffer PointsTo
+ {
+ get { return pointsTo; }
+ }
- public Boolean IsInitialized
- {
- get { return storage != UNKNOWN; }
- }
+ public Boolean IsTainted
+ {
+ get { return tainted; }
- public UInt32 Value
- {
- get { return storage; }
- }
+ private set { tainted = value; }
+ }
- public Boolean IsPointer
- {
- get { return pointsTo != null; }
- }
+ public Boolean IsOOB
+ {
+ get { return isOOB; }
+ set { isOOB = value; }
+ }
- public override String ToString()
- {
- String result = String.Empty;
+ public Boolean IsInitialized
+ {
+ get { return storage != UNKNOWN; }
+ }
- if (tainted)
- result += "t";
+ public UInt32 Value
+ {
+ get { return storage; }
+ }
- UInt32 valueToPrint = this.Value;
+ public Boolean IsPointer
+ {
+ get { return pointsTo != null; }
+ }
- if (pointsTo != null)
+ public override String ToString()
{
- AbstractValue pointer = pointsTo[0];
+ String result = String.Empty;
- StringBuilder newResult = new StringBuilder(result);
+ if (tainted)
+ result += "t";
- const Byte maximumPointerDepth = 100;
- Int32 count = maximumPointerDepth;
- while ((pointer != null) && (count-- > 0))
+ UInt32 valueToPrint = this.Value;
+
+ if (pointsTo != null)
{
- newResult.Append("*");
+ AbstractValue pointer = pointsTo[0];
- if (pointer.PointsTo != null)
+ StringBuilder newResult = new StringBuilder(result);
+
+ const Byte maximumPointerDepth = 100;
+ Int32 count = maximumPointerDepth;
+ while ((pointer != null) && (count-- > 0))
{
- pointer = pointer.PointsTo[0];
+ newResult.Append("*");
+
+ if (pointer.PointsTo != null)
+ {
+ pointer = pointer.PointsTo[0];
+ }
+ else
+ {
+ valueToPrint = pointer.Value;
+ pointer = null;
+ }
}
- else
- {
- valueToPrint = pointer.Value;
- pointer = null;
- }
+ result = newResult.ToString();
}
- result = newResult.ToString();
- }
- if (valueToPrint != UNKNOWN)
- {
- result += String.Format("0x{0:x8}", valueToPrint);
+ if (valueToPrint != UNKNOWN)
+ {
+ result += String.Format("0x{0:x8}", valueToPrint);
+ }
+ else
+ {
+ result += "?";
+ }
+
+ return result;
}
- else
- {
- result += "?";
- }
-
- return result;
}
}
-}
Added: AbstractValueTest.cs
===================================================================
--- AbstractValueTest.cs (rev 0)
+++ AbstractValueTest.cs 2009-01-05 02:07:15 UTC (rev 159)
@@ -0,0 +1,203 @@
+// This file is part of bugreport.
+// Copyright (c) 2006-2009 The bugreport Developers.
+// See AUTHORS.txt for details.
+// Licensed under the GNU General Public License, Version 3 (GPLv3).
+// See LICENSE.txt for details.
+
+using NUnit.Framework;
+using System;
+
+namespace bugreport
+{
+ [TestFixture]
+ public class AbstractValueTest
+ {
+ AbstractValue pointer;
+ AbstractBuffer buffer;
+
+ [Test]
+ public void NotInitialized()
+ {
+ AbstractValue uninitializedValue = new AbstractValue();
+ Assert.IsFalse(uninitializedValue.IsInitialized);
+ Assert.AreEqual(AbstractValue.UNKNOWN, uninitializedValue.Value);
+ Assert.AreEqual("?", uninitializedValue.ToString());
+ }
+
+ [Test]
+ public void Initialized()
+ {
+ AbstractValue uninit = new AbstractValue(0xabcdef);
+ Assert.IsTrue(uninit.IsInitialized);
+ Assert.AreEqual(0xabcdef, uninit.Value);
+ }
+
+ [Test]
+ public void Equals()
+ {
+ Assert.IsFalse(new AbstractValue().Equals(null));
+ }
+
+ [Test]
+ public void PointerHashcodes()
+ {
+ pointer = new AbstractValue(new[] {new AbstractValue(1)});
+ var pointer2 = new AbstractValue(new[] {new AbstractValue(2)});
+
+ Assert.AreNotEqual(pointer.GetHashCode(), pointer2.GetHashCode());
+ }
+
+ [Test]
+ public void AssignmentAtByteZero()
+ {
+ var buffer = AbstractValue.GetNewBuffer(16);
+ pointer = new AbstractValue(buffer);
+ pointer.PointsTo[0] = new AbstractValue(0x31337);
+ Assert.AreEqual(0x31337, pointer.PointsTo[0].Value);
+ Assert.AreEqual("*0x00031337", pointer.ToString());
+ }
+
+ [Test]
+ public void AssignmentAtEnd()
+ {
+ AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
+ pointer = new AbstractValue(buffer);
+ pointer.PointsTo[15] = new AbstractValue(0x31337);
+ Assert.AreEqual(0x31337, pointer.PointsTo[15].Value);
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void ZeroSizeBuffer()
+ {
+ pointer = new AbstractValue(new AbstractValue[] {});
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentNullException))]
+ public void NullCopyCtor()
+ {
+ pointer = new AbstractValue((AbstractValue)null);
+ }
+
+ [Test]
+ public void TruncateValue()
+ {
+ AbstractValue dwordValue = new AbstractValue(0xdeadbeef);
+ AbstractValue byteValue = dwordValue.TruncateValueToByte();
+ Assert.AreEqual(0xef, byteValue.Value);
+ }
+
+ [Test]
+ public void AddTaintIf()
+ {
+ AbstractValue clean = new AbstractValue(0x31337);
+ Assert.IsFalse(clean.IsTainted);
+ AbstractValue notTainted = clean.AddTaintIf(0 == 1);
+ Assert.IsFalse(notTainted.IsTainted);
+ Assert.AreSame(clean, notTainted);
+
+ AbstractValue tainted = clean.AddTaintIf(1 == 1);
+ Assert.IsTrue(tainted.IsTainted);
+ Assert.AreNotSame(clean, tainted);
+ }
+
+ [Test]
+ public void AddTaint()
+ {
+ AbstractValue clean = new AbstractValue(0x31337);
+ Assert.IsFalse(clean.IsTainted);
+ AbstractValue tainted = clean.AddTaint();
+ Assert.IsTrue(tainted.IsTainted);
+ Assert.AreNotSame(clean, tainted);
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidOperationException))]
+ public void AddTaintOnPointer()
+ {
+ AbstractBuffer buffer = new AbstractBuffer(AbstractValue.GetNewBuffer(1));
+ AbstractValue clean = new AbstractValue(buffer);
+ clean.AddTaint();
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void EmptyBuffer()
+ {
+ pointer = new AbstractValue(new AbstractBuffer(new AbstractValue[] {}));
+ }
+
+ [Test]
+ public void NoPointer()
+ {
+ AbstractValue value = new AbstractValue(2).AddTaint();
+
+ Assert.IsNull(value.PointsTo);
+ StringAssert.Contains("0x00000002", value.ToString());
+ StringAssert.Contains("t", value.ToString());
+
+ }
+
+ [Test]
+ public void Pointer()
+ {
+ buffer = new AbstractBuffer(new AbstractValue[] {new AbstractValue(2)});
+ pointer = new AbstractValue(buffer);
+ Assert.AreEqual(2, pointer.PointsTo[0].Value);
+ StringAssert.StartsWith("*0x00000002", pointer.ToString());
+ }
+
+ [Test]
+ public void PointerPointer()
+ {
+ buffer = new AbstractBuffer(new AbstractValue[] {new AbstractValue(2)});
+ pointer = new AbstractValue(buffer);
+ AbstractValue pointerPointer = new AbstractValue(new AbstractValue[] {pointer});
+ Assert.AreEqual(2, pointerPointer.PointsTo[0].PointsTo[0].Value);
+ StringAssert.StartsWith("**0x00000002", pointerPointer.ToString());
+ }
+
+ [Test]
+ public void PointerPointerPointer()
+ {
+ buffer = new AbstractBuffer(new AbstractValue[] {new AbstractValue(2)});
+ pointer = new AbstractValue(buffer);
+ AbstractValue pointerPointer = new AbstractValue(new AbstractValue[] {pointer});
+ AbstractValue pointerPointerPointer = new AbstractValue(new AbstractValue[] {pointerPointer});
+ Assert.AreEqual(2, pointerPointerPointer.PointsTo[0].PointsTo[0].PointsTo[0].Value);
+
+ StringAssert.StartsWith("***0x00000002", pointerPointerPointer.ToString());
+ }
+
+ [Test]
+ public void CheckOOBAfterCopy()
+ {
+ AbstractValue src = new AbstractValue(0x31337);
+ src.IsOOB = false;
+ AbstractValue dest = new AbstractValue(0x1);
+ dest.IsOOB = true;
+ dest = new AbstractValue(src);
+
+ Assert.IsFalse(dest.IsOOB);
+ }
+
+ [Test]
+ public void PreserveIsOOBAfterCopy()
+ {
+ AbstractValue src = new AbstractValue(0x31337);
+ AbstractValue dest = new AbstractValue(0x1);
+ src.IsOOB = true;
+ dest = new AbstractValue(src);
+
+ Assert.IsTrue(dest.IsOOB);
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentOutOfRangeException))]
+ public void RequestedBufferTooLarge()
+ {
+ AbstractValue.GetNewBuffer(AbstractValue.MAX_BUFFER_SIZE + 1);
+ }
+ }
+}
Deleted: AbstractValueTests.cs
===================================================================
--- AbstractValueTests.cs 2008-09-11 02:15:48 UTC (rev 158)
+++ AbstractValueTests.cs 2009-01-05 02:07:15 UTC (rev 159)
@@ -1,202 +0,0 @@
-// Copyright (c) 2006-2008 Luis Miras, Doug Coker, Todd Nagengast,
-// Anthony Lineberry, Dan Moniz, Bryan Siepert, Mike Seery, Cullen Bryan
-// Licensed under GPLv3 draft 3
-// See LICENSE.txt for details.
-
-using NUnit.Framework;
-using System;
-
-namespace bugreport
-{
-[TestFixture]
-public class AbstractValueTests
-{
- AbstractValue pointer;
- AbstractBuffer buffer;
-
- [Test]
- public void NotInitialized()
- {
- AbstractValue uninitializedValue = new AbstractValue();
- Assert.IsFalse(uninitializedValue.IsInitialized);
- Assert.AreEqual(AbstractValue.UNKNOWN, uninitializedValue.Value);
- Assert.AreEqual("?", uninitializedValue.ToString());
- }
-
- [Test]
- public void Initialized()
- {
- AbstractValue uninit = new AbstractValue(0xabcdef);
- Assert.IsTrue(uninit.IsInitialized);
- Assert.AreEqual(0xabcdef, uninit.Value);
- }
-
- [Test]
- public void Equals()
- {
- Assert.IsFalse(new AbstractValue().Equals(null));
- }
-
- [Test]
- public void PointerHashcodes()
- {
- pointer = new AbstractValue(new[] {new AbstractValue(1)});
- var pointer2 = new AbstractValue(new[] {new AbstractValue(2)});
-
- Assert.AreNotEqual(pointer.GetHashCode(), pointer2.GetHashCode());
- }
-
- [Test]
- public void AssignmentAtByteZero()
- {
- var buffer = AbstractValue.GetNewBuffer(16);
- pointer = new AbstractValue(buffer);
- pointer.PointsTo[0] = new AbstractValue(0x31337);
- Assert.AreEqual(0x31337, pointer.PointsTo[0].Value);
- Assert.AreEqual("*0x00031337", pointer.ToString());
- }
-
- [Test]
- public void AssignmentAtEnd()
- {
- AbstractValue[] buffer = AbstractValue.GetNewBuffer(16);
- pointer = new AbstractValue(buffer);
- pointer.PointsTo[15] = new AbstractValue(0x31337);
- Assert.AreEqual(0x31337, pointer.PointsTo[15].Value);
- }
-
- [Test]
- [ExpectedException(typeof(ArgumentException))]
- public void ZeroSizeBuffer()
- {
- pointer = new AbstractValue(new AbstractValue[] {});
- }
-
- [Test]
- [ExpectedException(typeof(ArgumentNullException))]
- public void NullCopyCtor()
- {
- pointer = new AbstractValue((AbstractValue)null);
- }
-
- [Test]
- public void TruncateValue()
- {
- AbstractValue dwordValue = new AbstractValue(0xdeadbeef);
- AbstractValue byteValue = dwordValue.TruncateValueToByte();
- Assert.AreEqual(0xef, byteValue.Value);
- }
-
- [Test]
- public void AddTaintIf()
- {
- AbstractValue clean = new AbstractValue(0x31337);
- Assert.IsFalse(clean.IsTainted);
- AbstractValue notTainted = clean.AddTaintIf(0 == 1);
- Assert.IsFalse(notTainted.IsTainted);
- Assert.AreSame(clean, notTainted);
-
- AbstractValue tainted = clean.AddTaintIf(1 == 1);
- Assert.IsTrue(tainted.IsTainted);
- Assert.AreNotSame(clean, tainted);
- }
-
- [Test]
- public void AddTaint()
- {
- AbstractValue clean = new AbstractValue(0x31337);
- Assert.IsFalse(clean.IsTainted);
- AbstractValue tainted = clean.AddTaint();
- Assert.IsTrue(tainted.IsTainted);
- Assert.AreNotSame(clean, tainted);
- }
-
- [Test]
- [ExpectedException(typeof(InvalidOperationException))]
- public void AddTaintOnPointer()
- {
- AbstractBuffer buffer = new AbstractBuffer(AbstractValue.GetNewBuffer(1));
- AbstractValue clean = new AbstractValue(buffer);
- clean.AddTaint();
- }
-
- [Test]
- [ExpectedException(typeof(ArgumentException))]
- public void EmptyBuffer()
- {
- pointer = new AbstractValue(new AbstractBuffer(new AbstractValue[] {}));
- }
-
- [Test]
- public void NoPointer()
- {
- AbstractValue value = new AbstractValue(2).AddTaint();
-
- Assert.IsNull(value.PointsTo);
- StringAssert.Contains("0x00000002", value.ToString());
- StringAssert.Contains("t", value.ToString());
-
- }
-
- [Test]
- public void Pointer()
- {
- buffer = new AbstractBuffer(new AbstractValue[] {new AbstractValue(2)});
- pointer = new AbstractValue(buffer);
- Assert.AreEqual(2, pointer.PointsTo[0].Value);
- StringAssert.StartsWith("*0x00000002", pointer.ToString());
- }
-
- [Test]
- public void PointerPointer()
- {
- buffer = new AbstractBuffer(new AbstractValue[] {new AbstractValue(2)});
- pointer = new AbstractValue(buffer);
- AbstractValue pointerPointer = new AbstractValue(new AbstractValue[] {pointer});
- Assert.AreEqual(2, pointerPointer.PointsTo[0].PointsTo[0].Value);
- StringAssert.StartsWith("**0x00000002", pointerPointer.ToString());
- }
-
- [Test]
- public void PointerPointerPointer()
- {
- buffer = new AbstractBuffer(new AbstractValue[] {new AbstractValue(2)});
- pointer = new AbstractValue(buffer);
- AbstractValue pointerPointer = new AbstractValue(new AbstractValue[] {pointer});
- AbstractValue pointerPointerPointer = new AbstractValue(new AbstractValue[] {pointerPointer});
- Assert.AreEqual(2, pointerPointerPointer.PointsTo[0].PointsTo[0].PointsTo[0].Value);
-
- StringAssert.StartsWith("***0x00000002", pointerPointerPointer.ToString());
- }
-
- [Test]
- public void CheckOOBAfterCopy()
- {
- AbstractValue src = new AbstractValue(0x31337);
- src.IsOOB = false;
- AbstractValue dest = new AbstractValue(0x1);
- dest.IsOOB = true;
- dest = new AbstractValue(src);
-
- Assert.IsFalse(dest.IsOOB);
- }
-
- [Test]
- public void PreserveIsOOBAfterCopy()
- {
- AbstractValue src = new AbstractValue(0x31337);
- AbstractValue dest = new AbstractValue(0x1);
- src.IsOOB = true;
- dest = new AbstractValue(src);
-
- Assert.IsTrue(dest.IsOOB);
- }
-
- [Test]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- public void RequestedBufferTooLarge()
- {
- AbstractValue.GetNewBuffer(AbstractValue.MAX_BUFFER_SIZE + 1);
- }
-}
-}
Modified: AnalysisEngine.csproj
===================================================================
--- AnalysisEngine.csproj 2008-09-11 02:15:48 UTC (rev 158)
+++ AnalysisEngine.csproj 2009-01-05 02:07:15 UTC (rev 159)
@@ -60,6 +60,10 @@
<Compile Include="AbstractValueTests.cs" />
<Compile Include="Analyzer.cs" />
<Compile Include="AnalyzerTests.cs" />
+ <Compile Include="ArmEmulator.cs" />
+ <Compile Include="ArmEmulatorTest.cs" />
+ <Compile Include="ArmOpcode.cs" />
+ <Compile Include="ArmOpcodeTest.cs" />
<Compile Include="Contract.cs" />
<Compile Include="CoverageExcludeAttribute.cs" />
<Compile Include="ElfFileParser.cs" />
Modified: Analyzer.cs
===================================================================
--- Analyzer.cs 2008-09-11 02:15:48 UTC (rev 158)
+++ Analyzer.cs 2009-01-05 02:07:15 UTC (rev 159)
@@ -1,6 +1,7 @@
-// Copyright (c) 2006-2008 Luis Miras, Doug Coker, Todd Nagengast,
-// Anthony Lineberry, Dan Moniz, Bryan Siepert, Mike Seery, Cullen Bryan
-// Licensed under GPLv3 draft 3
+// This file is part of bugreport.
+// Copyright (c) 2006-2009 The bugreport Developers.
+// See AUTHORS.txt for details.
+// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
using System;
@@ -8,171 +9,171 @@
namespace bugreport
{
-public class EmulationEventArgs : EventArgs
-{
- private readonly MachineState state;
- private readonly ReadOnlyCollection<Byte> code;
-
- public EmulationEventArgs(MachineState state, ReadOnlyCollection<Byte> code)
+ public class EmulationEventArgs : EventArgs
{
- this.state = state;
- this.code = code;
- }
+ private readonly MachineState state;
+ private readonly ReadOnlyCollection<Byte> code;
- public MachineState MachineState
- {
- get { return state; }
+ public EmulationEventArgs(MachineState state, ReadOnlyCollection<Byte> code)
+ {
+ this.state = state;
+ this.code = code;
+ }
+
+ public MachineState MachineState
+ {
+ get { return state; }
+ }
+
+ public ReadOnlyCollection<Byte> Code
+ {
+ get { return code; }
+ }
}
- public ReadOnlyCollection<Byte> Code
+ public class ReportEventArgs : EventArgs
{
- get { return code; }
- }
-}
+ private readonly ReportItem reportItem;
-public class ReportEventArgs : EventArgs
-{
- private readonly ReportItem reportItem;
+ public ReportEventArgs(ReportItem reportItem)
+ {
+ this.reportItem = reportItem;
+ }
- public ReportEventArgs(ReportItem reportItem)
- {
- this.reportItem = reportItem;
+ public ReportItem ReportItem
+ {
+ get { return reportItem; }
+ }
}
- public ReportItem ReportItem
+ public class ReportCollection : Collection<ReportItem>
{
- get { return reportItem; }
- }
-}
+ public EventHandler<ReportEventArgs> OnReport;
-public class ReportCollection : Collection<ReportItem>
-{
- public EventHandler<ReportEventArgs> OnReport;
+ protected override void InsertItem(int index, ReportItem item)
+ {
+ base.InsertItem(index, item);
- protected override void InsertItem(int index, ReportItem item)
- {
- base.InsertItem(index, item);
-
- if (null != OnReport)
- {
- OnReport(this, new ReportEventArgs(item));
+ if (null != OnReport)
+ {
+ OnReport(this, new ReportEventArgs(item));
+ }
}
}
-}
-public class Analyzer
-{
- public EventHandler<EmulationEventArgs> OnEmulationComplete;
+ public class Analyzer
+ {
+ public EventHandler<EmulationEventArgs> OnEmulationComplete;
- protected ReportCollection reportItems;
- private readonly IParsable parser;
- private readonly Opcode opcode = new X86Opcode();
+ protected ReportCollection reportItems;
+ private readonly IParsable parser;
+ private readonly Opcode opcode = new X86Opcode();
- public Analyzer(IParsable parser)
- {
- if (null == parser)
+ public Analyzer(IParsable parser)
{
- throw new ArgumentNullException("parser");
- }
+ if (null == parser)
+ {
+ throw new ArgumentNullException("parser");
+ }
- this.parser = parser;
+ this.parser = parser;
- reportItems = new ReportCollection();
- }
+ reportItems = new ReportCollection();
+ }
- public ReadOnlyCollection<ReportItem> ActualReportItems
- {
- get
+ public ReadOnlyCollection<ReportItem> ActualReportItems
{
- return new ReadOnlyCollection<ReportItem>(reportItems);
+ get
+ {
+ return new ReadOnlyCollection<ReportItem>(reportItems);
+ }
}
- }
- public ReadOnlyCollection<ReportItem> ExpectedReportItems
- {
- get
+ public ReadOnlyCollection<ReportItem> ExpectedReportItems
{
- return parser.ExpectedReportItems;
+ get
+ {
+ return parser.ExpectedReportItems;
+ }
}
- }
- public EventHandler<ReportEventArgs> OnReport
- {
- get { return reportItems.OnReport; }
- set { reportItems.OnReport = value; }
- }
+ public EventHandler<ReportEventArgs> OnReport
+ {
+...
[truncated message content] |
|
From: Matt <ma...@us...> - 2009-01-05 00:43:46
|
On Sun, 4 Jan 2009, Dan Moniz wrote: > In looking through the current Subversion revision checkout I have, I > notice one file, DebuggerCommandTest.cs, which has Matt and a new > person, "Huy" mentioned. The commit message in Subversion, however, > mentions Matt and "Hung". Hung is a friend who I was doing some pairing/TDD exercises with to find and fix bugs. Since the changes were considered non-significant, by legal standards, and I got his permission on IM, you can just remove his name from the credits. (I was hoping we would have regular TDD "dates", but it didn't work out that way.) > Matt, can you let us know what the other contributor's correct name > is? I'll add him to the list of copyright holders, along with you, and > I'll finish updating the copyright date to reflect 2009, new > contributors, and moving to GPLv3 final. For the rest of the list: Dan and I agreed on IM to add an AUTHORS file and a standard comment header that references it, like other open source projects do. > Speaking of which, Matt and Huy/Hung: can both of you please approve, > abstain, or disapprove (via mail to this list) of moving the license > to GPLv3 final from GPLv3 draft 3 (as per the others)? Hung verbally relinquished his copyrights. I, of course, approve changing to the final GPLv3 license. -- tangled strands of DNA explain the way that I behave. http://www.clock.org/~matt |
|
From: Dan M. <dn...@po...> - 2009-01-04 22:45:25
|
On Sun, Jan 4, 2009 at 5:22 PM, Luis Miras <lm...@gm...> wrote: > sounds good to me > > On Sun, Jan 4, 2009 at 1:50 AM, Michael Seery <ms...@ya...> wrote: >> >> I am in favor of switching to the final GPLv3 license for bugreport. Awesome, thanks guys. In looking through the current Subversion revision checkout I have, I notice one file, DebuggerCommandTest.cs, which has Matt and a new person, "Huy" mentioned. The commit message in Subversion, however, mentions Matt and "Hung". Matt, can you let us know what the other contributor's correct name is? I'll add him to the list of copyright holders, along with you, and I'll finish updating the copyright date to reflect 2009, new contributors, and moving to GPLv3 final. Speaking of which, Matt and Huy/Hung: can both of you please approve, abstain, or disapprove (via mail to this list) of moving the license to GPLv3 final from GPLv3 draft 3 (as per the others)? Thanks again everybody! -- Dan Moniz <dn...@po...> [http://pobox.com/~dnm/] |
|
From: Luis M. <lm...@gm...> - 2009-01-04 22:22:26
|
sounds good to me On Sun, Jan 4, 2009 at 1:50 AM, Michael Seery <ms...@ya...> wrote: > > I am in favor of switching to the final GPLv3 license for bugreport. > > What else do we get to vote on? =) > > --Michael Seery > ms...@ya... > > > > > > > ------------------------------------------------------------------------------ > _______________________________________________ > bugreport-developers mailing list > bug...@li... > https://lists.sourceforge.net/lists/listinfo/bugreport-developers > |
|
From: Michael S. <ms...@ya...> - 2009-01-04 00:50:26
|
I am in favor of switching to the final GPLv3 license for bugreport.
What else do we get to vote on? =)
--Michael Seery
ms...@ya...
|
|
From: Dan M. <dn...@po...> - 2009-01-02 22:22:08
|
Back in September, I sent a mail to this list asking the following listed copyright holders to weigh in on moving to the final version of GPLv3, instead of the GPLv3 draft 3 the code is (currently still) under: Luis Miras Doug Coker Todd Nagengast Anthony Lineberry Dan Moniz (me) Bryan Siepert Mike Seery Cullen Bryan I count five responses to that request, from: Todd Nagengast Doug Coker Bryan Siepert Anthony Lineberry Cullen Bryan Listed copyright holders who still have yet to respond are: Luis Miras Dan Moniz (me) Mike Seery With the current list of replies received, the breakdown is as follows (the question being "do you approve changing the bugreport license to the final version of GPLv3 from the current license of the code, GPLv3 draft 3?"): Todd Nagengast: Abstain Doug Coker: Approve Bryan Siepert: Abstain Anthony Lineberry: Approve Cullen Bryan: Approve To add my own vote to this list, I hereby abstain. That brings us to: Todd Nagengast: Abstain Doug Coker: Approve Bryan Siepert: Abstain Anthony Lineberry: Approve Cullen Bryan: Approve Dan Moniz: Abstain Currently then: "Do you approve changing the bugreport license to the final version of GPLv3 from the current license of the code, GPLv3 draft 3?" Approve: three (3) votes Disapprove: zero (0) votes Abstain: three (3) votes I'd prefer Luis and Mike to weigh in as well before moving to GPLv3 officially. I am not a lawyer, and I don't know what would happen in the case of a disapprove vote (would simple majority suffice, or do we need unanimity?), but I'm willing to cross that bridge when we come to it. Thanks again for your support and help. -- Dan Moniz <dn...@po...> [http://pobox.com/~dnm/] |
|
From: Cullen B. <cu...@ho...> - 2008-09-11 21:42:22
|
I have no qualms with this either... Cullen > Date: Thu, 11 Sep 2008 09:59:16 -0700 > From: dc...@dv... > To: bug...@li... > Subject: Re: [bugreport-developers] Moving to the official GPLv3? > > I approve changing the license to GPLv3. > > > On Sat, Aug 23, 2008 at 08:27:18PM -0400, Dan Moniz wrote: > > bugreport is currently still licensed under GPLv3 draft 3. The final > > version of GPLv3 has been out for more than a year now. We should > > either move to GPLv3 to remedy the issue of licensing under a draft > > version of the GPL, or move to a different license. I'm uncomfortable > > with the GPL personally and would prefer a simpler and more permissive > > license (Matt and I have had several discussions about licensing at > > various times), but my contribution to the code and project has been > > minimal to date, and I think others aren't terribly concerned about > > the licensing particulars. > > > > Current copyright on bugreport is held by several people (see below), > > and each of us should send an email to > > bug...@li... conveying assent or dissent > > to moving to the final, released version of GPLv3. > > > > Luis Miras > > Doug Coker > > Todd Nagengast > > Anthony Lineberry > > Dan Moniz > > Bryan Siepert > > Mike Seery > > Cullen Bryan > > > > Thanks for your help. > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > bugreport-developers mailing list > bug...@li... > https://lists.sourceforge.net/lists/listinfo/bugreport-developers _________________________________________________________________ See how Windows Mobile brings your life together—at home, work, or on the go. http://clk.atdmt.com/MRT/go/msnnkwxp1020093182mrt/direct/01/ |
|
From: Anthony L. <ant...@gm...> - 2008-09-11 21:40:11
|
My code contributions are small, but I vote GPLv3 as well -- Anthony Lineberry On Thu, Sep 11, 2008 at 10:21 AM, sBs <sid...@gm...> wrote: > I'll abstain, as I'm not sure I'm responsible for a single line of code. > -bryan > > On Thu, Sep 11, 2008 at 9:59 AM, <dc...@dv...> wrote: >> I approve changing the license to GPLv3. >> >> >> On Sat, Aug 23, 2008 at 08:27:18PM -0400, Dan Moniz wrote: >>> bugreport is currently still licensed under GPLv3 draft 3. The final >>> version of GPLv3 has been out for more than a year now. We should >>> either move to GPLv3 to remedy the issue of licensing under a draft >>> version of the GPL, or move to a different license. I'm uncomfortable >>> with the GPL personally and would prefer a simpler and more permissive >>> license (Matt and I have had several discussions about licensing at >>> various times), but my contribution to the code and project has been >>> minimal to date, and I think others aren't terribly concerned about >>> the licensing particulars. >>> >>> Current copyright on bugreport is held by several people (see below), >>> and each of us should send an email to >>> bug...@li... conveying assent or dissent >>> to moving to the final, released version of GPLv3. >>> >>> Luis Miras >>> Doug Coker >>> Todd Nagengast >>> Anthony Lineberry >>> Dan Moniz >>> Bryan Siepert >>> Mike Seery >>> Cullen Bryan >>> >>> Thanks for your help. >> >> ------------------------------------------------------------------------- >> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge >> Build the coolest Linux based applications with Moblin SDK & win great prizes >> Grand prize is a trip for two to an Open Source event anywhere in the world >> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >> _______________________________________________ >> bugreport-developers mailing list >> bug...@li... >> https://lists.sourceforge.net/lists/listinfo/bugreport-developers >> > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > bugreport-developers mailing list > bug...@li... > https://lists.sourceforge.net/lists/listinfo/bugreport-developers > |
|
From: sBs <sid...@gm...> - 2008-09-11 17:21:06
|
I'll abstain, as I'm not sure I'm responsible for a single line of code. -bryan On Thu, Sep 11, 2008 at 9:59 AM, <dc...@dv...> wrote: > I approve changing the license to GPLv3. > > > On Sat, Aug 23, 2008 at 08:27:18PM -0400, Dan Moniz wrote: >> bugreport is currently still licensed under GPLv3 draft 3. The final >> version of GPLv3 has been out for more than a year now. We should >> either move to GPLv3 to remedy the issue of licensing under a draft >> version of the GPL, or move to a different license. I'm uncomfortable >> with the GPL personally and would prefer a simpler and more permissive >> license (Matt and I have had several discussions about licensing at >> various times), but my contribution to the code and project has been >> minimal to date, and I think others aren't terribly concerned about >> the licensing particulars. >> >> Current copyright on bugreport is held by several people (see below), >> and each of us should send an email to >> bug...@li... conveying assent or dissent >> to moving to the final, released version of GPLv3. >> >> Luis Miras >> Doug Coker >> Todd Nagengast >> Anthony Lineberry >> Dan Moniz >> Bryan Siepert >> Mike Seery >> Cullen Bryan >> >> Thanks for your help. > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > bugreport-developers mailing list > bug...@li... > https://lists.sourceforge.net/lists/listinfo/bugreport-developers > |
|
From: <dc...@dv...> - 2008-09-11 16:59:05
|
I approve changing the license to GPLv3. On Sat, Aug 23, 2008 at 08:27:18PM -0400, Dan Moniz wrote: > bugreport is currently still licensed under GPLv3 draft 3. The final > version of GPLv3 has been out for more than a year now. We should > either move to GPLv3 to remedy the issue of licensing under a draft > version of the GPL, or move to a different license. I'm uncomfortable > with the GPL personally and would prefer a simpler and more permissive > license (Matt and I have had several discussions about licensing at > various times), but my contribution to the code and project has been > minimal to date, and I think others aren't terribly concerned about > the licensing particulars. > > Current copyright on bugreport is held by several people (see below), > and each of us should send an email to > bug...@li... conveying assent or dissent > to moving to the final, released version of GPLv3. > > Luis Miras > Doug Coker > Todd Nagengast > Anthony Lineberry > Dan Moniz > Bryan Siepert > Mike Seery > Cullen Bryan > > Thanks for your help. |