[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haiku-commits
Subject:    [haiku-commits] haiku: hrev45433 - src/servers/keystore
From:       mmlr () mlotz ! ch
Date:       2013-03-31 16:36:32
Message-ID: 20130331163632.64C6A5C06B3 () vmrepo ! haiku-os ! org
[Download RAW message or body]

hrev45433 adds 1 changeset to branch 'master'
old head: fa21184f24d35e0c1e3dddae0a2981d05861e494
new head: 32057ce92279831f060782646fa67ea7161019f9
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=32057ce+%5Efa21184

----------------------------------------------------------------------------

32057ce: If a keyring is empty, store a no data flag instead of failing.
  
  Any fully empty keyring (no keys and no applications) would fail to add
  the empty flat buffer and thus prevent the whole keystore database from
  being stored. This could easily happen when you used separate keyrings
  but the master keyring was left unused for example.
  
  Adding a flag that tells that there is no data allows us to distinguish
  between a case where the stored data is missing due to a problem versus
  an actually empty buffer.

                                            [ Michael Lotz <mmlr@mlotz.ch> ]

----------------------------------------------------------------------------

Revision:    hrev45433
Commit:      32057ce92279831f060782646fa67ea7161019f9
URL:         http://cgit.haiku-os.org/haiku/commit/?id=32057ce
Author:      Michael Lotz <mmlr@mlotz.ch>
Date:        Sun Mar 31 16:30:39 2013 UTC

----------------------------------------------------------------------------

1 file changed, 11 insertions(+), 2 deletions(-)
src/servers/keystore/Keyring.cpp | 13 +++++++++++--

----------------------------------------------------------------------------

diff --git a/src/servers/keystore/Keyring.cpp b/src/servers/keystore/Keyring.cpp
index 8392716..fbf11b4 100644
--- a/src/servers/keystore/Keyring.cpp
+++ b/src/servers/keystore/Keyring.cpp
@@ -42,6 +42,11 @@ Keyring::ReadFromMessage(const BMessage& message)
 	if (result != B_OK)
 		return result;
 
+	if (message.GetBool("noData", false)) {
+		fFlatBuffer.SetSize(0);
+		return B_OK;
+	}
+
 	ssize_t size;
 	const void* data;
 	result = message.FindData("data", B_RAW_TYPE, &data, &size);
@@ -69,8 +74,12 @@ Keyring::WriteToMessage(BMessage& message)
 	if (result != B_OK)
 		return result;
 
-	result = message.AddData("data", B_RAW_TYPE, fFlatBuffer.Buffer(),
-		fFlatBuffer.BufferLength());
+	if (fFlatBuffer.BufferLength() == 0)
+		result = message.AddBool("noData", true);
+	else {
+		result = message.AddData("data", B_RAW_TYPE, fFlatBuffer.Buffer(),
+			fFlatBuffer.BufferLength());
+	}
 	if (result != B_OK)
 		return result;
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic