[srp-server] update validation of instance and service names (#8080)

This commit updates `ProcessServiceDiscoveryInstructions()` method
to use `Dns::Name::IsSubDomainOf()` to validate the relation between
service instance name and the base service name.
This commit is contained in:
Abtin Keshavarzian
2022-08-25 11:11:35 -07:00
committed by GitHub
parent d72c10eed3
commit 958eb5c5bf
+2 -4
View File
@@ -931,10 +931,8 @@ Error Server::ProcessServiceDiscoveryInstructions(Host & aHost,
}
// Verify that instance name and service name are related.
VerifyOrExit(
StringEndsWith(instanceName, isSubType ? subServiceName : serviceName, kStringCaseInsensitiveMatch),
error = kErrorFailed);
VerifyOrExit(Dns::Name::IsSubDomainOf(instanceName, isSubType ? subServiceName : serviceName),
error = kErrorFailed);
// Ensure the same service does not exist already.
VerifyOrExit(aHost.FindService(serviceName, instanceName) == nullptr, error = kErrorFailed);