mirror of
https://github.com/systemd/systemd.git
synced 2025-03-09 12:58:26 +03:00
resolved: tighten the rules a bit on valid DNS-SD service identifiers
Let's insist that the ID is suitable for inclusion in a filename, as one of the most basic of requirements.
This commit is contained in:
parent
0ef0e2691a
commit
c903d3df6f
@ -11,6 +11,7 @@
|
||||
#include "format-util.h"
|
||||
#include "memory-util.h"
|
||||
#include "missing_capability.h"
|
||||
#include "path-util.h"
|
||||
#include "resolved-bus.h"
|
||||
#include "resolved-def.h"
|
||||
#include "resolved-dns-stream.h"
|
||||
@ -1898,13 +1899,16 @@ static int bus_method_register_service(sd_bus_message *message, void *userdata,
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
s = hashmap_get(m->dnssd_services, id);
|
||||
if (s)
|
||||
return sd_bus_error_setf(error, BUS_ERROR_DNSSD_SERVICE_EXISTS, "DNS-SD service '%s' exists already", id);
|
||||
if (!filename_part_is_valid(id))
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "DNS-SD service identifier '%s' is invalid", id);
|
||||
|
||||
if (!dnssd_srv_type_is_valid(type))
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "DNS-SD service type '%s' is invalid", type);
|
||||
|
||||
s = hashmap_get(m->dnssd_services, id);
|
||||
if (s)
|
||||
return sd_bus_error_setf(error, BUS_ERROR_DNSSD_SERVICE_EXISTS, "DNS-SD service '%s' exists already", id);
|
||||
|
||||
service->id = strdup(id);
|
||||
if (!service->id)
|
||||
return log_oom();
|
||||
|
Loading…
x
Reference in New Issue
Block a user