resolve: refuse invalid service without type field

Fixes Fixes #33935.
This commit is contained in:
Yu Watanabe 2024-08-05 10:46:41 +09:00
parent cc194dddc2
commit b48ab08732
2 changed files with 10 additions and 0 deletions

View File

@ -1148,6 +1148,11 @@ static void resolve_service_all_complete(DnsQuery *query) {
if (r < 0) if (r < 0)
goto finish; goto finish;
if (isempty(type)) {
r = reply_method_errorf(q, BUS_ERROR_NO_SUCH_SERVICE, "'%s' does not provide valid service", dns_query_string(q));
goto finish;
}
r = sd_bus_message_append( r = sd_bus_message_append(
reply, reply,
"ssst", "ssst",

View File

@ -828,6 +828,11 @@ static void resolve_service_all_complete(DnsQuery *query) {
if (r < 0) if (r < 0)
goto finish; goto finish;
if (isempty(type)) {
r = sd_varlink_error(q->varlink_request, "io.systemd.Resolve.ServiceNotProvided", NULL);
goto finish;
}
r = sd_varlink_replybo( r = sd_varlink_replybo(
query->varlink_request, query->varlink_request,
SD_JSON_BUILD_PAIR("services", SD_JSON_BUILD_VARIANT(srv)), SD_JSON_BUILD_PAIR("services", SD_JSON_BUILD_VARIANT(srv)),