diff options
author | Andres Morales <anmorales@google.com> | 2015-03-25 18:01:05 -0700 |
---|---|---|
committer | Andres Morales <anmorales@google.com> | 2015-03-25 18:58:26 -0700 |
commit | 175eea9a2a921314d1a58c3be0bc57a71bd8e62d (patch) | |
tree | c8303c66d5ff7f2ac732fa7930cd24401553bae4 /gatekeeper_messages.cpp | |
parent | b0bf8febf0e2606790d606d52b26671c68ffb0f4 (diff) | |
download | gatekeeper-175eea9a2a921314d1a58c3be0bc57a71bd8e62d.tar.gz |
Populate error when deserializing gatekeeper error messages
Change-Id: Id016c1c9b7fe7f0f4efffc1407ae8cec45d20418
Diffstat (limited to 'gatekeeper_messages.cpp')
-rw-r--r-- | gatekeeper_messages.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gatekeeper_messages.cpp b/gatekeeper_messages.cpp index abcedf9..cc700b1 100644 --- a/gatekeeper_messages.cpp +++ b/gatekeeper_messages.cpp @@ -26,7 +26,7 @@ namespace gatekeeper { * Methods for serializing/deserializing SizedBuffers */ -struct serial_header_t { +struct __attribute__((__packed__)) serial_header_t { uint32_t error; uint32_t user_id; }; @@ -72,7 +72,7 @@ size_t GateKeeperMessage::GetSerializedSize() const { size_t GateKeeperMessage::Serialize(uint8_t *buffer, const uint8_t *end) const { size_t bytes_written = 0; - if (buffer + GetSerializedSize() != end) { + if (buffer + GetSerializedSize() > end) { return 0; } @@ -101,6 +101,8 @@ gatekeeper_error_t GateKeeperMessage::Deserialize(const uint8_t *payload, const if (payload == end) return ERROR_INVALID; user_id = header->user_id; error = nonErrorDeserialize(payload + sizeof(*header), end); + } else { + error = static_cast<gatekeeper_error_t>(header->error); } return error; |