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 <[email protected]>
Commit-Queue: Jocelyn Bohr <[email protected]>
Tested-by: Jocelyn Bohr <[email protected]>
14 files changed
tree: 97c604edeaaa5834d4f4d870df23ef13b7876765
  1. generator/
  2. .gitignore
  3. _TPM_Hash_Data.c
  4. _TPM_Hash_Data_fp.h
  5. _TPM_Hash_End.c
  6. _TPM_Hash_End_fp.h
  7. _TPM_Hash_Start.c
  8. _TPM_Hash_Start_fp.h
  9. _TPM_Init.c
  10. ActivateCredential.c
  11. ActivateCredential_fp.h
  12. AlgorithmCap.c
  13. AlgorithmCap_fp.h
  14. Attest_spt.c
  15. Attest_spt_fp.h
  16. BaseTypes.h
  17. Bits.c
  18. bits.h
  19. Bits_fp.h
  20. bool.h
  21. Cancel.c
  22. Capabilities.h
  23. Certify.c
  24. Certify_fp.h
  25. CertifyCreation.c
  26. CertifyCreation_fp.h
  27. ChangeEPS.c
  28. ChangeEPS_fp.h
  29. ChangePPS.c
  30. ChangePPS_fp.h
  31. Clear.c
  32. Clear_fp.h
  33. ClearControl.c
  34. ClearControl_fp.h
  35. Clock.c
  36. ClockRateAdjust.c
  37. ClockRateAdjust_fp.h
  38. ClockSet.c
  39. ClockSet_fp.h
  40. CommandAttributeData.c
  41. CommandAudit.c
  42. CommandAudit_fp.h
  43. CommandCodeAttributes.c
  44. CommandCodeAttributes_fp.h
  45. CommandDispatcher_fp.h
  46. Commands_fp.h
  47. COMMIT-QUEUE.ini
  48. Commit.c
  49. Commit_fp.h
  50. Context_spt.c
  51. Context_spt_fp.h
  52. ContextLoad.c
  53. ContextLoad_fp.h
  54. ContextSave.c
  55. ContextSave_fp.h
  56. CpriCryptPri.c
  57. CpriCryptPri_fp.h
  58. CpriDataEcc.c
  59. CpriDataEcc.h
  60. CpriECC.c
  61. CpriECC_fp.h
  62. CpriHash.c
  63. CpriHash_fp.h
  64. CpriHashData.c
  65. CpriMisc.c
  66. CpriMisc_fp.h
  67. CpriRNG.c
  68. CpriRNG_fp.h
  69. CpriRSA.c
  70. CpriRSA_fp.h
  71. CpriSym.c
  72. CpriSym_fp.h
  73. Create.c
  74. Create_fp.h
  75. CreatePrimary.c
  76. CreatePrimary_fp.h
  77. CryptoEngine.h
  78. CryptSelfTest.c
  79. CryptSelfTest_fp.h
  80. CryptUtil.c
  81. CryptUtil_fp.h
  82. DA.c
  83. DA_fp.h
  84. DictionaryAttackLockReset.c
  85. DictionaryAttackLockReset_fp.h
  86. DictionaryAttackParameters.c
  87. DictionaryAttackParameters_fp.h
  88. DRTM.c
  89. Duplicate.c
  90. Duplicate_fp.h
  91. EC_Ephemeral.c
  92. EC_Ephemeral_fp.h
  93. ECC_Parameters.c
  94. ECC_Parameters_fp.h
  95. ECDH_KeyGen.c
  96. ECDH_KeyGen_fp.h
  97. ECDH_ZGen.c
  98. ECDH_ZGen_fp.h
  99. EncryptDecrypt.c
  100. EncryptDecrypt_fp.h
  101. Entity.c
  102. Entity_fp.h
  103. Entropy.c
  104. EventSequenceComplete.c
  105. EventSequenceComplete_fp.h
  106. EvictControl.c
  107. EvictControl_fp.h
  108. ExecCommand.c
  109. FieldUpgradeData.c
  110. FieldUpgradeData_fp.h
  111. FieldUpgradeStart.c
  112. FieldUpgradeStart_fp.h
  113. FirmwareRead.c
  114. FirmwareRead_fp.h
  115. FlushContext.c
  116. FlushContext_fp.h
  117. GetCapability.c
  118. GetCapability_fp.h
  119. GetCommandAuditDigest.c
  120. GetCommandAuditDigest_fp.h
  121. GetRandom.c
  122. GetRandom_fp.h
  123. GetSessionAuditDigest.c
  124. GetSessionAuditDigest_fp.h
  125. GetTestResult.c
  126. GetTestResult_fp.h
  127. GetTime.c
  128. GetTime_fp.h
  129. Global.c
  130. Global.h
  131. Handle.c
  132. Handle_fp.h
  133. HandleProcess_fp.h
  134. Hash.c
  135. Hash_fp.h
  136. HashSequenceStart.c
  137. HashSequenceStart_fp.h
  138. Hierarchy.c
  139. Hierarchy_fp.h
  140. HierarchyChangeAuth.c
  141. HierarchyChangeAuth_fp.h
  142. HierarchyControl.c
  143. HierarchyControl_fp.h
  144. HMAC.c
  145. HMAC_fp.h
  146. HMAC_Start.c
  147. HMAC_Start_fp.h
  148. Implementation.h
  149. Import.c
  150. Import_fp.h
  151. IncrementalSelfTest.c
  152. IncrementalSelfTest_fp.h
  153. InternalRoutines.h
  154. LICENSE
  155. Load.c
  156. Load_fp.h
  157. LoadExternal.c
  158. LoadExternal_fp.h
  159. Locality.c
  160. Locality_fp.h
  161. LocalityPlat.c
  162. MakeCredential.c
  163. MakeCredential_fp.h
  164. Makefile
  165. Manufacture.c
  166. Manufacture_fp.h
  167. marshal_fp.h
  168. marshal_test.c
  169. MathFunctions.c
  170. MathFunctions_fp.h
  171. MemoryLib.c
  172. MemoryLib_fp.h
  173. NV.c
  174. NV_Certify.c
  175. NV_Certify_fp.h
  176. NV_ChangeAuth.c
  177. NV_ChangeAuth_fp.h
  178. NV_DefineSpace.c
  179. NV_DefineSpace_fp.h
  180. NV_Extend.c
  181. NV_Extend_fp.h
  182. NV_fp.h
  183. NV_GlobalWriteLock.c
  184. NV_GlobalWriteLock_fp.h
  185. NV_Increment.c
  186. NV_Increment_fp.h
  187. NV_Read.c
  188. NV_Read_fp.h
  189. NV_ReadLock.c
  190. NV_ReadLock_fp.h
  191. NV_ReadPublic.c
  192. NV_ReadPublic_fp.h
  193. NV_SetBits.c
  194. NV_SetBits_fp.h
  195. NV_spt.c
  196. NV_spt_fp.h
  197. NV_UndefineSpace.c
  198. NV_UndefineSpace_fp.h
  199. NV_UndefineSpaceSpecial.c
  200. NV_UndefineSpaceSpecial_fp.h
  201. NV_Write.c
  202. NV_Write_fp.h
  203. NV_WriteLock.c
  204. NV_WriteLock_fp.h
  205. NVMem.c
  206. Object.c
  207. Object_fp.h
  208. Object_spt.c
  209. Object_spt_fp.h
  210. ObjectChangeAuth.c
  211. ObjectChangeAuth_fp.h
  212. OsslCryptoEngine.h
  213. parsep3
  214. parsep4
  215. part3.txt
  216. part4.txt
  217. PCR.c
  218. PCR_Allocate.c
  219. PCR_Allocate_fp.h
  220. PCR_Event.c
  221. PCR_Event_fp.h
  222. PCR_Extend.c
  223. PCR_Extend_fp.h
  224. PCR_fp.h
  225. PCR_Read.c
  226. PCR_Read_fp.h
  227. PCR_Reset.c
  228. PCR_Reset_fp.h
  229. PCR_SetAuthPolicy.c
  230. PCR_SetAuthPolicy_fp.h
  231. PCR_SetAuthValue.c
  232. PCR_SetAuthValue_fp.h
  233. Platform.h
  234. PlatformData.c
  235. PlatformData.h
  236. Policy_spt.c
  237. Policy_spt_fp.h
  238. PolicyAuthorize.c
  239. PolicyAuthorize_fp.h
  240. PolicyAuthValue.c
  241. PolicyAuthValue_fp.h
  242. PolicyCommandCode.c
  243. PolicyCommandCode_fp.h
  244. PolicyCounterTimer.c
  245. PolicyCounterTimer_fp.h
  246. PolicyCpHash.c
  247. PolicyCpHash_fp.h
  248. PolicyDuplicationSelect.c
  249. PolicyDuplicationSelect_fp.h
  250. PolicyGetDigest.c
  251. PolicyGetDigest_fp.h
  252. PolicyLocality.c
  253. PolicyLocality_fp.h
  254. PolicyNameHash.c
  255. PolicyNameHash_fp.h
  256. PolicyNV.c
  257. PolicyNV_fp.h
  258. PolicyNvWritten.c
  259. PolicyNvWritten_fp.h
  260. PolicyOR.c
  261. PolicyOR_fp.h
  262. PolicyPassword.c
  263. PolicyPassword_fp.h
  264. PolicyPCR.c
  265. PolicyPCR_fp.h
  266. PolicyPhysicalPresence.c
  267. PolicyPhysicalPresence_fp.h
  268. PolicyRestart.c
  269. PolicyRestart_fp.h
  270. PolicySecret.c
  271. PolicySecret_fp.h
  272. PolicySigned.c
  273. PolicySigned_fp.h
  274. PolicyTicket.c
  275. PolicyTicket_fp.h
  276. Power.c
  277. Power_fp.h
  278. PowerPlat.c
  279. PP.c
  280. PP_Commands.c
  281. PP_Commands_fp.h
  282. PP_fp.h
  283. PPPlat.c
  284. PRESUBMIT.cfg
  285. PropertyCap.c
  286. PropertyCap_fp.h
  287. Quote.c
  288. Quote_fp.h
  289. ReadClock.c
  290. ReadClock_fp.h
  291. README
  292. ReadPublic.c
  293. ReadPublic_fp.h
  294. Rewrap.c
  295. Rewrap_fp.h
  296. RSA_Decrypt.c
  297. RSA_Decrypt_fp.h
  298. RSA_Encrypt.c
  299. RSA_Encrypt_fp.h
  300. RSAData.c
  301. RSAKeySieve.c
  302. RSAKeySieve.h
  303. RSAKeySieve_fp.h
  304. SelfTest.c
  305. SelfTest_fp.h
  306. SequenceComplete.c
  307. SequenceComplete_fp.h
  308. SequenceUpdate.c
  309. SequenceUpdate_fp.h
  310. Session.c
  311. Session_fp.h
  312. SessionProcess.c
  313. SessionProcess_fp.h
  314. SetAlgorithmSet.c
  315. SetAlgorithmSet_fp.h
  316. SetCommandCodeAuditStatus.c
  317. SetCommandCodeAuditStatus_fp.h
  318. SetPrimaryPolicy.c
  319. SetPrimaryPolicy_fp.h
  320. Shutdown.c
  321. Shutdown_fp.h
  322. Sign.c
  323. Sign_fp.h
  324. StartAuthSession.c
  325. StartAuthSession_fp.h
  326. Startup.c
  327. Startup_fp.h
  328. StirRandom.c
  329. StirRandom_fp.h
  330. swap.h
  331. TcpServer.c
  332. TestParms.c
  333. TestParms_fp.h
  334. Ticket.c
  335. Ticket_fp.h
  336. Time.c
  337. Time_fp.h
  338. Tpm.h
  339. tpm_generated.c
  340. tpm_generated.h
  341. TPM_Types.h
  342. TPMB.h
  343. TpmBuildSwitches.h
  344. TPMCmdp.c
  345. TPMCmds.c
  346. TpmError.h
  347. TpmFail.c
  348. TpmFail_fp.h
  349. TpmTcpProtocol.h
  350. Unique.c
  351. Unique_fp.h
  352. Unseal.c
  353. Unseal_fp.h
  354. VendorString.h
  355. VerifySignature.c
  356. VerifySignature_fp.h
  357. ZGen_2Phase.c
  358. ZGen_2Phase_fp.h