Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(957)

Unified Diff: src/tcs/tcsi_random.c

Issue 3581012: Upgrade from trousers 0.3.3 to 0.3.6 and from testsuite 0.2 to 0.3. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/trousers.git
Patch Set: git cl push Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/tcs/tcsi_own.c ('k') | src/tcsd/Makefile.am » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/tcs/tcsi_random.c
diff --git a/src/tcs/tcsi_random.c b/src/tcs/tcsi_random.c
index 5fa0436a983983de3d4bc49dc21a2cf146828b26..9670df44686236c45356a59e4fc0ac144433c284 100644
--- a/src/tcs/tcsi_random.c
+++ b/src/tcs/tcsi_random.c
@@ -40,10 +40,10 @@ TCSP_GetRandom_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
UINT32 * bytesRequested, /* in, out */
BYTE ** randomBytes) /* out */
{
- UINT64 offset = 0;
+ UINT64 offset;
TSS_RESULT result;
UINT32 paramSize, totalReturned = 0, bytesReturned, retries = 50;
- BYTE txBlob[TSS_TPM_TXBLOB_SIZE], *rnd_tmp = NULL;
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE], *rnd_tmp = NULL, *rnd_tmp2 = NULL;
LogDebugFn("%u bytes", *bytesRequested);
@@ -51,6 +51,7 @@ TCSP_GetRandom_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
return result;
do {
+ offset = 0;
if ((result = tpm_rqu_build(TPM_ORD_GetRandom, &offset, txBlob,
*bytesRequested - totalReturned, NULL)))
break;
@@ -78,15 +79,16 @@ TCSP_GetRandom_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
&bytesReturned, &rnd_tmp, NULL, NULL)))
break;
- *randomBytes = realloc(*randomBytes, totalReturned + bytesReturned);
- if (*randomBytes == NULL) {
+ rnd_tmp2 = realloc(*randomBytes, totalReturned + bytesReturned);
+ if (rnd_tmp2 == NULL) {
free(rnd_tmp);
rnd_tmp = NULL;
LogError("malloc of %u bytes failed.", bytesReturned);
result = TCSERR(TSS_E_OUTOFMEMORY);
break;
}
- memcpy(*randomBytes, rnd_tmp, bytesReturned);
+ *randomBytes = rnd_tmp2;
+ memcpy(*randomBytes + totalReturned, rnd_tmp, bytesReturned);
free(rnd_tmp);
rnd_tmp = NULL;
#endif
« no previous file with comments | « src/tcs/tcsi_own.c ('k') | src/tcsd/Makefile.am » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698