tools/xenstored: Harden corrupt()
authorJulien Grall <jgrall@amazon.com>
Tue, 12 Jul 2022 09:12:13 +0000 (11:12 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 12 Jul 2022 09:12:13 +0000 (11:12 +0200)
commit81ee3d08351be1ef2a14d371993604098d6a4673
tree82b4ea512c8b6f8421d701ed873616b9d8e17c9c
parent5cb8142076ce1ce53eafd7e00acb4d0eac4e7784
tools/xenstored: Harden corrupt()

At the moment, corrupt() is neither checking for allocation failure
nor freeing the allocated memory.

Harden the code by printing ENOMEM if the allocation failed and
free 'str' after the last use.

This is not considered to be a security issue because corrupt() should
only be called when Xenstored thinks the database is corrupted. Note
that the trigger (i.e. a guest reliably provoking the call) would be
a security issue.

Fixes: 06d17943f0cd ("Added a basic integrity checker, and some basic ability to recover from store")
Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
master commit: db3382dd4f468c763512d6bf91c96773395058fb
master date: 2022-06-23 13:44:10 +0100
tools/xenstore/xenstored_core.c