diff options
author | John Salem <josalem@microsoft.com> | 2019-08-19 14:49:43 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-19 14:49:43 -0700 |
commit | fc18c3d7f63b4507f4bf8144b2ee43e96ead0731 (patch) | |
tree | 64ae322cfca434d2e21175192488c3bf13c19a8d /src/vm | |
parent | d662cf107823b670139bf2d134fa0d5d5a8dc474 (diff) | |
download | coreclr-fc18c3d7f63b4507f4bf8144b2ee43e96ead0731.tar.gz coreclr-fc18c3d7f63b4507f4bf8144b2ee43e96ead0731.tar.bz2 coreclr-fc18c3d7f63b4507f4bf8144b2ee43e96ead0731.zip |
Account for quoted values in provider filter string (#26159) (#26195)
* Account for quoted values in provider filter string
Diffstat (limited to 'src/vm')
-rw-r--r-- | src/vm/eventpipeprovider.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/vm/eventpipeprovider.cpp b/src/vm/eventpipeprovider.cpp index 4148aa131a..c2e56ffed5 100644 --- a/src/vm/eventpipeprovider.cpp +++ b/src/vm/eventpipeprovider.cpp @@ -225,17 +225,33 @@ void EventPipeProvider::AddEvent(EventPipeEvent &event) // of pairs of null terminated strings. The first member of the pair is // the key and the second is the value. // To convert to this format we need to convert all '=' and ';' - // characters to '\0'. + // characters to '\0', except when in a quoted string. SString dstBuffer; SString(pFilterData).ConvertToUTF8(dstBuffer); const COUNT_T BUFFER_SIZE = dstBuffer.GetCount() + 1; buffer.AllocThrows(BUFFER_SIZE); + BOOL isQuotedValue = false; + COUNT_T j = 0; for (COUNT_T i = 0; i < BUFFER_SIZE; ++i) - buffer[i] = (dstBuffer[i] == '=' || dstBuffer[i] == ';') ? '\0' : dstBuffer[i]; + { + // if a value is a quoted string, leave the quotes out from the destination + // and don't replace `=` or `;` characters until leaving the quoted section + // e.g., key="a;value=";foo=bar --> { key\0a;value=\0foo\0bar\0 } + if (dstBuffer[i] == '"') + { + isQuotedValue = !isQuotedValue; + continue; + } + buffer[j++] = ((dstBuffer[i] == '=' || dstBuffer[i] == ';') && !isQuotedValue) ? '\0' : dstBuffer[i]; + } + + // In case we skipped over quotes in the filter string, shrink the buffer size accordingly + if (j < dstBuffer.GetCount()) + buffer.Shrink(j + 1); eventFilterDescriptor.Ptr = reinterpret_cast<ULONGLONG>(buffer.Ptr()); - eventFilterDescriptor.Size = static_cast<ULONG>(BUFFER_SIZE); + eventFilterDescriptor.Size = static_cast<ULONG>(buffer.Size()); eventFilterDescriptor.Type = 0; // EventProvider.cs: `internal enum ControllerCommand.Update` isEventFilterDescriptorInitialized = true; } |