[Ikvm-commit] ikvm/runtime ClassFile.cs,1.125,1.126
Brought to you by:
jfrijters
|
From: Jeroen F. <jfr...@us...> - 2014-06-03 07:14:07
|
Update of /cvsroot/ikvm/ikvm/runtime In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv1655 Modified Files: ClassFile.cs Log Message: Malformed MethodParameters attribute should not throw ClassFormatError. Index: ClassFile.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/ClassFile.cs,v retrieving revision 1.125 retrieving revision 1.126 diff -C2 -d -r1.125 -r1.126 *** ClassFile.cs 27 May 2014 12:32:26 -0000 1.125 --- ClassFile.cs 3 Jun 2014 07:14:04 -0000 1.126 *************** *** 2921,2936 **** throw new ClassFormatError("{0} (Duplicate MethodParameters attribute)", classFile.Name); } ! BigEndianBinaryReader rdr = br.Section(br.ReadUInt32()); ! byte parameters_count = rdr.ReadByte(); ! parameters = new MethodParametersEntry[parameters_count]; ! for(int j = 0; j < parameters_count; j++) ! { ! parameters[j].name = classFile.GetConstantPoolUtf8String(utf8_cp, rdr.ReadUInt16()); ! parameters[j].flags = rdr.ReadUInt16(); ! } ! if(!rdr.IsAtEnd) ! { ! throw new ClassFormatError("{0} (MethodParameters attribute has wrong length)", classFile.Name); ! } break; } --- 2921,2925 ---- throw new ClassFormatError("{0} (Duplicate MethodParameters attribute)", classFile.Name); } ! parameters = ReadMethodParameters(br, utf8_cp); break; } *************** *** 2961,2964 **** --- 2950,2979 ---- } + private static MethodParametersEntry[] ReadMethodParameters(BigEndianBinaryReader br, string[] utf8_cp) + { + uint length = br.ReadUInt32(); + if(length > 0) + { + BigEndianBinaryReader rdr = br.Section(length); + byte parameters_count = rdr.ReadByte(); + if(length == 1 + parameters_count * 4) + { + MethodParametersEntry[] parameters = new MethodParametersEntry[parameters_count]; + for(int j = 0; j < parameters_count; j++) + { + ushort name = rdr.ReadUInt16(); + if(name <= 0 || name >= utf8_cp.Length || utf8_cp[name] == null) + { + return MethodParametersEntry.Malformed; + } + parameters[j].name = utf8_cp[name]; + parameters[j].flags = rdr.ReadUInt16(); + } + return parameters; + } + } + return MethodParametersEntry.Malformed; + } + protected override void ValidateSig(ClassFile classFile, string descriptor) { *************** *** 3168,3171 **** --- 3183,3194 ---- } + internal bool MalformedMethodParameters + { + get + { + return parameters == MethodParametersEntry.Malformed; + } + } + internal bool HasJsr { *************** *** 3752,3755 **** --- 3775,3779 ---- internal struct MethodParametersEntry { + internal static readonly MethodParametersEntry[] Malformed = new MethodParametersEntry[0]; internal string name; internal ushort flags; |