When sending file from a Linux host to a Windows remote, Linux host will try to copy the source file's permission bits, which will contain _S_I?GRP and _S_I?OTH bits. Those bits are rejected by _wsopen_s, causing it to return EINVAL.
This patch masks out the rejected bits.
GitHub issue: #64313
Nitpick: comments are usually on the line before.