[folks] Fix saving the key file when it contains multi-byte characters



commit 35ebac56b63a4d0a704c1a94ef7271dfcf266803
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Wed Sep 8 11:06:25 2010 +0100

    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

 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)
         {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]