mirror of
https://gitlab.gnome.org/GNOME/libsecret.git
synced 2025-01-03 02:28:53 +00:00
secret-file-collection: force little-endian in GVariant
As the GVariant serialization format does not record the original endianness of integer values, we need to ensure that it doesn't change between write and load.
This commit is contained in:
parent
9adf321442
commit
a54f5011fc
@ -287,7 +287,9 @@ on_load_contents (GObject *source_object,
|
|||||||
GVariant *variant;
|
GVariant *variant;
|
||||||
GVariant *salt_array;
|
GVariant *salt_array;
|
||||||
guint32 salt_size;
|
guint32 salt_size;
|
||||||
|
guint32 iteration_count;
|
||||||
guint64 modified_time;
|
guint64 modified_time;
|
||||||
|
guint64 usage_count;
|
||||||
gconstpointer data;
|
gconstpointer data;
|
||||||
gsize n_data;
|
gsize n_data;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
@ -365,11 +367,18 @@ on_load_contents (GObject *source_object,
|
|||||||
g_free,
|
g_free,
|
||||||
contents);
|
contents);
|
||||||
g_variant_get (variant, "(u@ayutu@a(a{say}ay))",
|
g_variant_get (variant, "(u@ayutu@a(a{say}ay))",
|
||||||
&salt_size, &salt_array, &self->iteration_count,
|
&salt_size, &salt_array, &iteration_count,
|
||||||
&modified_time, &self->usage_count,
|
&modified_time, &usage_count,
|
||||||
&self->items);
|
&self->items);
|
||||||
|
|
||||||
|
salt_size = GUINT32_FROM_LE(salt_size);
|
||||||
|
iteration_count = GUINT32_FROM_LE(iteration_count);
|
||||||
|
modified_time = GUINT64_FROM_LE(modified_time);
|
||||||
|
usage_count = GUINT32_FROM_LE(usage_count);
|
||||||
|
|
||||||
|
self->iteration_count = iteration_count;
|
||||||
self->modified = g_date_time_new_from_unix_utc (modified_time);
|
self->modified = g_date_time_new_from_unix_utc (modified_time);
|
||||||
|
self->usage_count = usage_count;
|
||||||
|
|
||||||
data = g_variant_get_fixed_array (salt_array, &n_data, sizeof(guint8));
|
data = g_variant_get_fixed_array (salt_array, &n_data, sizeof(guint8));
|
||||||
g_assert (n_data == salt_size);
|
g_assert (n_data == salt_size);
|
||||||
@ -796,11 +805,11 @@ secret_file_collection_write (SecretFileCollection *self,
|
|||||||
g_bytes_get_size (self->salt),
|
g_bytes_get_size (self->salt),
|
||||||
sizeof(guint8));
|
sizeof(guint8));
|
||||||
variant = g_variant_new ("(u@ayutu@a(a{say}ay))",
|
variant = g_variant_new ("(u@ayutu@a(a{say}ay))",
|
||||||
g_bytes_get_size (self->salt),
|
GUINT32_TO_LE(g_bytes_get_size (self->salt)),
|
||||||
salt_array,
|
salt_array,
|
||||||
self->iteration_count,
|
GUINT32_TO_LE(self->iteration_count),
|
||||||
g_date_time_to_unix (self->modified),
|
GUINT64_TO_LE(g_date_time_to_unix (self->modified)),
|
||||||
self->usage_count,
|
GUINT32_TO_LE(self->usage_count),
|
||||||
self->items);
|
self->items);
|
||||||
|
|
||||||
g_variant_get_data (variant); /* force serialize */
|
g_variant_get_data (variant); /* force serialize */
|
||||||
|
Loading…
Reference in New Issue
Block a user