Skip to content

SymUnmanagedWriter.DefineSequencePoints does not validate the length of offsets #463

Open

Description

@RaphaelFakhri

SymUnmanagedWriterImpl.DefineSequencePoints checks count against the lengths of startLines, startColumns, endLines and endColumns, but not offsets:

if (count < 0 || count > startLines.Length || count > startColumns.Length || count > endLines.Length || count > endColumns.Length)
{
    throw new ArgumentOutOfRangeException(nameof(count));
}

When offsets is shorter than count, no ArgumentOutOfRangeException is thrown. The arrays and count go to the native ISymUnmanagedWriter.DefineSequencePoints, which reads count elements from each buffer. The native writer reads past the end of the offsets buffer and writes whatever it finds there into the PDB as IL offsets.

Repro

var array = new int[2];
writer.DefineSequencePoints(documentIndex, count: 2, offsets: new int[1], array, array, array, array);

Expected: ArgumentOutOfRangeException, which is what happens when any of the other four arrays is too short.

Actual: no exception, and the call goes through to the native writer.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions