Commit f2dcc6f
pcr commands: Fix session leaks
All three PCR tools had session leaks in tpm2_tool_onstop():
- tpm2_pcrextend: Authorization sessions and auxiliary sessions were
set up but never closed, leaking all sessions.
- tpm2_pcrevent: The early return prevented auxiliary session cleanup,
leaking all auxiliary sessions.
- tpm2_pcrread: The auxiliary session cleanup section was completely
empty, leaking all auxiliary sessions.
This commit adds proper session cleanup to all three tools:
- Close authorization sessions with error checking
- Close auxiliary sessions in a loop with path guards
- Return accumulated error status
Signed-off-by: Zhirang Guo <jonny_guo@apple.com>1 parent 764b063 commit f2dcc6f
3 files changed
Lines changed: 43 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
453 | 453 | | |
454 | 454 | | |
455 | 455 | | |
456 | | - | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
457 | 461 | | |
458 | 462 | | |
459 | 463 | | |
460 | 464 | | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
461 | 476 | | |
462 | 477 | | |
463 | 478 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
239 | 244 | | |
240 | 245 | | |
241 | 246 | | |
242 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
243 | 257 | | |
244 | | - | |
| 258 | + | |
245 | 259 | | |
246 | 260 | | |
247 | 261 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
316 | 327 | | |
317 | | - | |
| 328 | + | |
318 | 329 | | |
319 | 330 | | |
320 | 331 | | |
| |||
0 commit comments