Skip to content

Commit

Permalink
Fix bug: pipe names could be read past their end.
Browse files Browse the repository at this point in the history
  • Loading branch information
grayed committed Aug 30, 2020
1 parent 0ef1b12 commit 37e3bf7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Native.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ public static IEnumerable<PipeModel> GetPipes(string pipeHost = ".")
FILE_DIRECTORY_INFORMATION fdi = PtrToStruct<FILE_DIRECTORY_INFORMATION>(tmp);
IntPtr namePtr = (IntPtr)(FILE_DIRECTORY_INFORMATION.FileNameOffset + tmp.ToInt64());

yield return new PipeModel(pipeHost, Marshal.PtrToStringUni(namePtr), (int)fdi.AllocationSize.LowPart, fdi.EndOfFile.LowPart, null /* TODO */);
// fdi.FileNameLength/2 - because FileNameLength is in bytes
yield return new PipeModel(pipeHost, Marshal.PtrToStringUni(namePtr, (int)fdi.FileNameLength/2), (int)fdi.AllocationSize.LowPart, fdi.EndOfFile.LowPart, null /* TODO */);

if (fdi.NextEntryOffset == 0)
break;
Expand Down

0 comments on commit 37e3bf7

Please sign in to comment.