fw_cfg: fix memory corruption when all fw_cfg slots are used
commitd6b6abc51dda79a97f2c7bd6652c1940c068f1ec
authorMarcel Apfelbaum <marcel@redhat.com>
Mon, 8 Jan 2018 21:50:07 +0000 (8 23:50 +0200)
committerEduardo Habkost <ehabkost@redhat.com>
Fri, 19 Jan 2018 13:18:51 +0000 (19 11:18 -0200)
treebbd0e7a39efd262c9196edea6d75a88d47557d8a
parentd342eb7662bcfe47c26615b67025ae59a383489d
fw_cfg: fix memory corruption when all fw_cfg slots are used

When all the fw_cfg slots are used, a write is made outside the
bounds of the fw_cfg files array as part of the sort algorithm.

Fix it by avoiding an unnecessary array element move.
Fix also an assert while at it.

Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Message-Id: <20180108215007.46471-1-marcel@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
hw/nvram/fw_cfg.c