-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NRBF] Address issues discovered by Threat Model #106629
Changes from all commits
d5addcb
38fb5f8
f89177c
77088c2
13306fc
297aa4b
ea50be4
e740b0a
140bf92
16394e2
a5a38fb
8a61178
2556647
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,26 +126,23 @@ | |
<data name="Serialization_UnexpectedNullRecordCount" xml:space="preserve"> | ||
<value>Unexpected Null Record count.</value> | ||
</data> | ||
<data name="Serialization_MaxArrayLength" xml:space="preserve"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this resource was not being used for a while |
||
<value>The serialized array length ({0}) was larger than the configured limit {1}.</value> | ||
</data> | ||
<data name="NotSupported_RecordType" xml:space="preserve"> | ||
<value>{0} Record Type is not supported by design.</value> | ||
</data> | ||
<data name="Serialization_InvalidReference" xml:space="preserve"> | ||
<value>Invalid member reference.</value> | ||
</data> | ||
<data name="Serialization_InvalidTypeName" xml:space="preserve"> | ||
<value>Invalid type name: `{0}`.</value> | ||
<value>Invalid type name.</value> | ||
</data> | ||
<data name="Serialization_TypeMismatch" xml:space="preserve"> | ||
<value>Expected the array to be of type {0}, but its element type was {1}.</value> | ||
</data> | ||
<data name="Serialization_InvalidTypeOrAssemblyName" xml:space="preserve"> | ||
<value>Invalid type or assembly name: `{0},{1}`.</value> | ||
<value>Invalid type or assembly name.</value> | ||
</data> | ||
<data name="Serialization_DuplicateMemberName" xml:space="preserve"> | ||
<value>Duplicate member name: `{0}`.</value> | ||
<value>Duplicate member name.</value> | ||
</data> | ||
<data name="Argument_NonSeekableStream" xml:space="preserve"> | ||
<value>Stream does not support seeking.</value> | ||
|
@@ -160,7 +157,7 @@ | |
<value>Only arrays with zero offsets are supported.</value> | ||
</data> | ||
<data name="Serialization_InvalidAssemblyName" xml:space="preserve"> | ||
<value>Invalid assembly name: `{0}`.</value> | ||
<value>Invalid assembly name.</value> | ||
</data> | ||
<data name="Serialization_InvalidFormat" xml:space="preserve"> | ||
<value>Invalid format.</value> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ public abstract class ArrayRecord : SerializationRecord | |
private protected ArrayRecord(ArrayInfo arrayInfo) | ||
{ | ||
ArrayInfo = arrayInfo; | ||
ValuesToRead = arrayInfo.TotalElementsCount; | ||
ValuesToRead = arrayInfo.FlattenedLength; | ||
} | ||
|
||
/// <summary> | ||
|
@@ -27,6 +27,12 @@ private protected ArrayRecord(ArrayInfo arrayInfo) | |
/// <value>A buffer of integers that represent the number of elements in every dimension.</value> | ||
public abstract ReadOnlySpan<int> Lengths { get; } | ||
|
||
/// <summary> | ||
/// When overridden in a derived class, gets the total number of all elements in every dimension. | ||
/// </summary> | ||
/// <value>A number that represent the total number of all elements in every dimension.</value> | ||
public virtual long FlattenedLength => ArrayInfo.FlattenedLength; | ||
|
||
/// <summary> | ||
/// Gets the rank of the array. | ||
/// </summary> | ||
|
@@ -44,7 +50,12 @@ private protected ArrayRecord(ArrayInfo arrayInfo) | |
|
||
internal long ValuesToRead { get; private protected set; } | ||
|
||
private protected ArrayInfo ArrayInfo { get; } | ||
internal ArrayInfo ArrayInfo { get; } | ||
|
||
internal bool IsJagged | ||
=> ArrayInfo.ArrayType == BinaryArrayType.Jagged | ||
// It is possible to have binary array records have an element type of array without being marked as jagged. | ||
|| TypeName.GetElementType().IsArray; | ||
Comment on lines
+57
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @JeremyKuhne this handles the scenario you have mentioned offline (there is also a test for that). Thank you again for pointing this out! |
||
|
||
/// <summary> | ||
/// Allocates an array and fills it with the data provided in the serialized records (in case of primitive types like <see cref="string"/> or <see cref="int"/>) or the serialized records themselves. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on what we have discussed and what @bartonjs wrote here: #103713 (comment)
I believe the type names and assembly names should not be provided in the exception messages.