From 906e0f802b56d26e7e0c65eba797fa8a596dee91 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Wed, 24 Apr 2019 14:44:03 -0700 Subject: message/pack: Check for outstanding bits Currently, if you pack a non-byte aligned member into a message and then pack an array, it will do the wrong thing and treat the unaligned data as being appended to the end of the message. Allowing for this behavior is convoluted and probably not useful, so just return an error. Change-Id: I6f200dbea96c41f49a110ba7536ccfd37115d277 Signed-off-by: William A. Kennington III --- include/ipmid/message/pack.hpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/ipmid') diff --git a/include/ipmid/message/pack.hpp b/include/ipmid/message/pack.hpp index 18863c4..deb0a5a 100644 --- a/include/ipmid/message/pack.hpp +++ b/include/ipmid/message/pack.hpp @@ -239,6 +239,10 @@ struct PackSingle> { static int op(Payload& p, const std::vector& t) { + if (p.bitCount != 0) + { + return 1; + } p.raw.reserve(p.raw.size() + t.size()); p.raw.insert(p.raw.end(), t.begin(), t.end()); return 0; -- cgit v1.2.1