report error if input buffer is larger than expected
Let's make the implementation exact and always return TPM_RC_SIZE if
unmarshaling returns success but there are some leftover data.
BUG=chrome-os-partner:43025
TEST=fixed test is described in https://goo.gl/kQnud0, all previously
passing tests still succeed
Change-Id: I05f9c86d4a2a93bc5cdf73d4e743d56c3d53bdaa
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/307602
Reviewed-by: Utkarsh Sanghi <usanghi@chromium.org>
diff --git a/Marshal_PolicyGetDigest.c b/Marshal_PolicyGetDigest.c
index 5bc768f..219ee7c 100644
--- a/Marshal_PolicyGetDigest.c
+++ b/Marshal_PolicyGetDigest.c
@@ -41,6 +41,9 @@
TPM_RC result = TPM_RC_SUCCESS;
// Get request handles from request_handles array.
target->policySession = request_handles[0];
+ if ((result == TPM_RC_SUCCESS) && *size) {
+ result = TPM_RC_SIZE;
+ }
return result;
}