Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/ikvm-fork.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjfrijters <jfrijters>2010-06-09 08:50:02 +0400
committerjfrijters <jfrijters>2010-06-09 08:50:02 +0400
commit6a205a316d24ab7bc88b010dcb84aab820fe6cda (patch)
treea4635aa05b72b5487d1f9f92cbd6d836814a6584 /reflect/Writer
parente8e6bf24d67f3b30b054d8f1b1afae70e085279b (diff)
Fix. When the user string heap overflows, throw an exception instead of silently creating corrupt image.
Diffstat (limited to 'reflect/Writer')
-rw-r--r--reflect/Writer/Heaps.cs7
1 files changed, 6 insertions, 1 deletions
diff --git a/reflect/Writer/Heaps.cs b/reflect/Writer/Heaps.cs
index ad9a019b..b8764d29 100644
--- a/reflect/Writer/Heaps.cs
+++ b/reflect/Writer/Heaps.cs
@@ -223,8 +223,13 @@ namespace IKVM.Reflection.Writer
int offset;
if (!strings.TryGetValue(str, out offset))
{
+ int length = str.Length * 2 + 1 + MetadataWriter.GetCompressedIntLength(str.Length * 2 + 1);
+ if (nextOffset + length > 0xFFFFFF)
+ {
+ throw new FileFormatLimitationExceededException("No logical space left to create more user strings.", FileFormatLimitationExceededException.META_E_STRINGSPACE_FULL);
+ }
offset = nextOffset;
- nextOffset += str.Length * 2 + 1 + MetadataWriter.GetCompressedIntLength(str.Length * 2 + 1);
+ nextOffset += length;
list.Add(str);
strings.Add(str, offset);
}