exported-object: make export_path D-Bus counter 64 bit
An overflow of the 32 bit guint is possible and rather ugly because the D-Bus path should be unique and not repeat. Avoid that by extending the counter to 64 bit.
This commit is contained in:
@@ -564,7 +564,7 @@ _create_export_path (NMExportedObjectClass *klass)
|
|||||||
{
|
{
|
||||||
const char *class_export_path, *p;
|
const char *class_export_path, *p;
|
||||||
static GHashTable *prefix_counters;
|
static GHashTable *prefix_counters;
|
||||||
guint *counter;
|
guint64 *counter;
|
||||||
|
|
||||||
class_export_path = klass->export_path;
|
class_export_path = klass->export_path;
|
||||||
|
|
||||||
@@ -575,17 +575,19 @@ _create_export_path (NMExportedObjectClass *klass)
|
|||||||
if (G_UNLIKELY (!prefix_counters))
|
if (G_UNLIKELY (!prefix_counters))
|
||||||
prefix_counters = g_hash_table_new (g_str_hash, g_str_equal);
|
prefix_counters = g_hash_table_new (g_str_hash, g_str_equal);
|
||||||
|
|
||||||
g_assert (p[1] == 'u');
|
nm_assert (p[1] == 'l');
|
||||||
g_assert (strchr (p + 1, '%') == NULL);
|
nm_assert (p[2] == 'l');
|
||||||
|
nm_assert (p[3] == 'u');
|
||||||
|
nm_assert (p[4] == '\0');
|
||||||
|
|
||||||
counter = g_hash_table_lookup (prefix_counters, class_export_path);
|
counter = g_hash_table_lookup (prefix_counters, class_export_path);
|
||||||
if (!counter) {
|
if (!counter) {
|
||||||
counter = g_slice_new0 (guint);
|
counter = g_slice_new0 (guint64);
|
||||||
g_hash_table_insert (prefix_counters, g_strdup (class_export_path), counter);
|
g_hash_table_insert (prefix_counters, g_strdup (class_export_path), counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
NM_PRAGMA_WARNING_DISABLE("-Wformat-nonliteral")
|
NM_PRAGMA_WARNING_DISABLE("-Wformat-nonliteral")
|
||||||
return g_strdup_printf (class_export_path, (*counter)++);
|
return g_strdup_printf (class_export_path, (long long unsigned) (*counter)++);
|
||||||
NM_PRAGMA_WARNING_REENABLE
|
NM_PRAGMA_WARNING_REENABLE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define NM_EXPORT_PATH_NUMBERED(basepath) ""basepath"/%u"
|
#define NM_EXPORT_PATH_NUMBERED(basepath) ""basepath"/%llu"
|
||||||
|
|
||||||
char *nm_exported_object_skeletonify_method_name (const char *dbus_method_name);
|
char *nm_exported_object_skeletonify_method_name (const char *dbus_method_name);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user