[SAMLIB] Check the server name in the binding routine

This commit is contained in:
Eric Kohl 2021-06-19 21:51:06 +02:00
parent 5b6e8af1bd
commit be65a8568b

View file

@ -77,6 +77,27 @@ PSAMPR_SERVER_NAME_bind(PSAMPR_SERVER_NAME pszSystemName)
TRACE("PSAMPR_SERVER_NAME_bind(%S)\n", pszSystemName);
/* Check the server name prefix and server name length */
if (pszSystemName != NULL)
{
int nLength = wcslen(pszSystemName);
int nNameLength = nLength;
if (nLength >= 1 && pszSystemName[0] == L'\\')
nNameLength--;
if (nLength >= 2 && pszSystemName[1] == L'\\')
nNameLength--;
if (((nLength - nNameLength != 0) &&
(nLength - nNameLength != 2)) ||
(nNameLength == 0))
{
WARN("Invalid server name %S", pszSystemName);
RpcRaiseException(STATUS_OBJECT_NAME_INVALID);
}
}
status = RpcStringBindingComposeW(NULL,
L"ncacn_np",
pszSystemName,