Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 03414aa

Browse files
authored
Fix ProcessStartInfo tests on CentOS in Debug (#26945)
There is a bug in CentOS7.1 getpwnam_r where it returns the wrong value if you pass in a buffer that is too small to hold the data. In Debug builds, we are purposefully passing in a buffer that is too small to test the fallback code, which is running into this OS bug. See https://bugs.centos.org/view.php?id=7324 Fixes #26673
1 parent 5cec1f3 commit 03414aa

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -624,13 +624,10 @@ private static (uint userId, uint groupId) GetUserAndGroupIds(ProcessStartInfo s
624624
private unsafe static (uint? userId, uint? groupId) GetUserAndGroupIds(string userName)
625625
{
626626
Interop.Sys.Passwd? passwd;
627-
#if DEBUG
628-
// Use an artificially small buffer in DEBUG to test the fallback path
629-
const int BufLen = 2;
630-
#else
631627
// First try with a buffer that should suffice for 99% of cases.
628+
// Note: on CentOS/RedHat 7.1 systems, getpwnam_r returns 'user not found' if the buffer is too small
629+
// see https://bugs.centos.org/view.php?id=7324
632630
const int BufLen = 1024;
633-
#endif
634631
byte* stackBuf = stackalloc byte[BufLen];
635632
if (TryGetPasswd(userName, stackBuf, BufLen, out passwd))
636633
{

0 commit comments

Comments
 (0)