]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemu_tpm: Don't crash if qemuTPMPcrBankBitmapToStr(NULL)
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 11 Aug 2022 18:57:02 +0000 (20:57 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Thu, 18 Aug 2022 14:00:07 +0000 (16:00 +0200)
commit78cc34cb99e22d660cbb77ae45f3ab62a08c0752
treee7e6ffe4138dbe6a16325e12b1c16ee5f49439c4
parent1f0a898ce3b3328e90e87bd09b2323408b02c058
qemu_tpm: Don't crash if qemuTPMPcrBankBitmapToStr(NULL)

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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_tpm.c