Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Enable int overflow/underflow checking
  • Loading branch information
Mike McLaughlin committed Sep 9, 2022
commit bb1215a955eabf6a65f82b80c4f1f40bb8da70a9
4 changes: 2 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net462'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private void ApplyRelocations(IModule module, PEReader reader, int dataVA, byte[
if ((offset + sizeof(uint)) <= data.Length)
{
uint value = BitConverter.ToUInt32(data, offset);
value += (uint)baseDelta;
value += unchecked((uint)baseDelta);
byte[] source = BitConverter.GetBytes(value);
Array.Copy(source, 0, data, offset, source.Length);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ internal bool Read(ulong address, byte[] buffer, int bufferSize, out int bytesRe
return _memoryService.ReadMemory(address, buffer, bufferSize, out bytesRead);
}

if (!_cacheValid || (address < _startCache) || (address > (_startCache + (ulong)(_cacheSize - bufferSize))))
if (!_cacheValid || (address < _startCache) || (address > (_startCache + (ulong)_cacheSize - (ulong)bufferSize)))
{
_cacheValid = false;
_startCache = address;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public ModuleFromDataReader(ModuleServiceFromDataReader moduleService, int modul

public override ulong ImageSize => _imageSize;

public override uint? IndexFileSize => _moduleInfo.IndexTimeStamp == InvalidTimeStamp ? null : (uint)_moduleInfo.IndexFileSize;
public override uint? IndexFileSize => _moduleInfo.IndexTimeStamp == InvalidTimeStamp ? null : unchecked((uint)_moduleInfo.IndexFileSize);

public override uint? IndexTimeStamp => _moduleInfo.IndexTimeStamp == InvalidTimeStamp ? null : (uint)_moduleInfo.IndexTimeStamp;
public override uint? IndexTimeStamp => _moduleInfo.IndexTimeStamp == InvalidTimeStamp ? null : unchecked((uint)_moduleInfo.IndexTimeStamp);

public override ImmutableArray<byte> BuildId
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public static object InvokeConstructor(Type type, IServiceProvider provider, boo
}
catch (TargetInvocationException ex)
{
Trace.TraceError(ex.ToString());
throw ex.InnerException;
}
}
Expand All @@ -148,6 +149,7 @@ public static object Invoke(MethodBase method, object instance, IServiceProvider
}
catch (TargetInvocationException ex)
{
Trace.TraceError(ex.ToString());
throw ex.InnerException;
}
}
Expand Down