From: Tom Gundersen Date: Mon, 9 Feb 2015 11:00:33 +0000 (+0100) Subject: networkd: bus - switch to properly escaped object paths X-Git-Tag: v219~108 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c8f5edeab0b007081cf89aeb1d23d428382c2a4f;p=platform%2Fupstream%2Fsystemd.git networkd: bus - switch to properly escaped object paths --- diff --git a/src/network/networkd-link-bus.c b/src/network/networkd-link-bus.c index 7c4f473..370707c 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);