[PATCH] qemu_tpm: Don't crash if qemuTPMPcrBankBitmapToStr(NULL)

Ján Tomko jtomko at redhat.com
Sun Aug 14 23:38:54 UTC 2022


On a Thursday in 2022, Michal Privoznik wrote:
>Historically, the tpm->data.emulator.activePcrBanks member was an
>unsigned int but since it was used as a bitmap it was converted
>to virBitmap type instead. Now, the virBitmap is allocated inside
>of virDomainTPMDefParseXML() but only if <activePcrBanks/> was
>found with at last one child element. Otherwise it stays NULL.
>
>Fast forward to starting a domain with TPM 2.0 and no
><activePcrBanks/> configured. Eventually,
>qemuTPMEmulatorBuildCommand() is called, which subsequently calls
>qemuTPMEmulatorReconfigure() and finally
>qemuTPMPcrBankBitmapToStr() passing the NULL value. Before
>rewrite to virBitmap this function would return NULL for empty
>activePcrBanks but now, well, now it crashes.
>
>Fixes: 52c7c31c8038aa31d502f59a40e4fb4ba9f61113
>Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
>---
> src/qemu/qemu_tpm.c | 3 +++
> 1 file changed, 3 insertions(+)
>

Reviewed-by: Ján Tomko <jtomko at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20220815/48a8311b/attachment.sig>


More information about the libvir-list mailing list