diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2010-09-08 11:06:25 +0100 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2010-09-10 12:22:29 +0100 |
commit | 35ebac56b63a4d0a704c1a94ef7271dfcf266803 (patch) | |
tree | 5b02af90174c60a6cd83aa4674b763f277eda810 | |
parent | c2c799bd5bd39de40ef17cdaa7050b6837b088ac (diff) |
Fix saving the key file when it contains multi-byte characters
The calculation of the length of the data to be saved was being done in
characters, not bytes, whereas the I/O function was expecting a length in
bytes. This caused some number of bytes to be dropped from the end of the
file, potentially splitting a multibyte character and breaking the file
encoding (not to mention losing data otherwise). Closes: bgo#628930
-rw-r--r-- | backends/key-file/kf-persona-store.vala | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/backends/key-file/kf-persona-store.vala b/backends/key-file/kf-persona-store.vala index 48e411d..885be12 100644 --- a/backends/key-file/kf-persona-store.vala +++ b/backends/key-file/kf-persona-store.vala @@ -232,8 +232,10 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore try { + /* Note: We have to use key_file_data.size () here to get its length + * in _bytes_ rather than _characters_. bgo#628930 */ yield this.file.replace_contents_async (key_file_data, - key_file_data.length, null, false, FileCreateFlags.PRIVATE); + key_file_data.size (), null, false, FileCreateFlags.PRIVATE); } catch (Error e) { |