diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/network/networkd-link-bus.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/network/networkd-link-bus.c b/src/network/networkd-link-bus.c index 7c4f47305b..370707c307 100644 --- a/src/network/networkd-link-bus.c +++ b/src/network/networkd-link-bus.c @@ -38,12 +38,18 @@ const sd_bus_vtable link_vtable[] = { }; static char *link_bus_path(Link *link) { + _cleanup_free_ char *ifindex = NULL; char *p; + int r; assert(link); assert(link->ifindex > 0); - if (asprintf(&p, "/org/freedesktop/network1/link/_%d", link->ifindex) < 0) + if (asprintf(&ifindex, "%d", link->ifindex) < 0) + return NULL; + + r = sd_bus_path_encode("/org/freedesktop/network1/link", ifindex, &p); + if (r < 0) return NULL; return p; @@ -80,6 +86,7 @@ int link_node_enumerator(sd_bus *bus, const char *path, void *userdata, char *** } int link_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) { + _cleanup_free_ char *identifier = NULL; Manager *m = userdata; Link *link; int ifindex, r; @@ -90,7 +97,11 @@ int link_object_find(sd_bus *bus, const char *path, const char *interface, void assert(m); assert(found); - if (sscanf(path, "/org/freedesktop/network1/link/_%d", &ifindex) != 1) + r = sd_bus_path_decode(path, "/org/freedesktop/network1/link", &identifier); + if (r < 0) + return 0; + + if (sscanf(identifier, "%d", &ifindex) != 1) return 0; r = link_get(m, ifindex, &link); |