aboutsummaryrefslogtreecommitdiff
path: root/Time.c
diff options
context:
space:
mode:
authorJocelyn Bohr <bohr@chromium.org>2015-07-29 15:14:01 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-07-30 18:57:42 +0000
commit32be40450906cd2c80dee4a83204931f7f3a2daa (patch)
tree97c604edeaaa5834d4f4d870df23ef13b7876765 /Time.c
parent9edfbac6a36e07e1a7ccb2260b6f65d97b45fef8 (diff)
downloadtpm2-32be40450906cd2c80dee4a83204931f7f3a2daa.tar.gz
Remove instances of calling marshal functions with NULL pointer.
In the code scraped from the TCG TPM2.0 Library specification, there are several instances where the intent is to marshal data into a buffer, but NULL pointer is passed in as size. Part 4 section 4.2.3.1 states: "If size is a NULL pointer, then no data is marshaled and the routine will compute the size of the memory required to marshal the indicated type." Implying these usages are bugs. This CL removes all instances of passing in NULL as size to a Marshal function when the intent is to marshal data. TEST=$ sudo emerge tpm2 builds libtpm2.a. Currently this is the only test we have for the scraped code. BUG=none Change-Id: If7b2a60f6a8e875b4a6eceab513dc22325bf4999 Reviewed-on: https://chromium-review.googlesource.com/289647 Reviewed-by: Utkarsh Sanghi <usanghi@chromium.org> Commit-Queue: Jocelyn Bohr <bohr@chromium.org> Tested-by: Jocelyn Bohr <bohr@chromium.org>
Diffstat (limited to 'Time.c')
-rw-r--r--Time.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Time.c b/Time.c
index 8d630bd..87c5ce2 100644
--- a/Time.c
+++ b/Time.c
@@ -195,12 +195,14 @@ TimeGetRange(
UINT16 infoSize;
BYTE infoData[sizeof(TPMS_TIME_INFO)];
BYTE *buffer;
+ INT32 bufferSize;
// Fill TPMS_TIME_INFO structure
timeInfo.time = g_time;
TimeFillInfo(&timeInfo.clockInfo);
// Marshal TPMS_TIME_INFO to canonical form
buffer = infoData;
- infoSize = TPMS_TIME_INFO_Marshal(&timeInfo, &buffer, NULL);
+ bufferSize = sizeof(TPMS_TIME_INFO);
+ infoSize = TPMS_TIME_INFO_Marshal(&timeInfo, &buffer, &bufferSize);
// Check if the input range is valid
if(offset + size > infoSize) return TPM_RC_RANGE;
// Copy info data to output buffer