From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43729) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0sOD-0003vz-9Y for qemu-devel@nongnu.org; Fri, 05 Jun 2015 10:14:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z0sOA-0006ie-Fg for qemu-devel@nongnu.org; Fri, 05 Jun 2015 10:14:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53370) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0sOA-0006iF-3n for qemu-devel@nongnu.org; Fri, 05 Jun 2015 10:14:26 -0400 From: Gerd Hoffmann Date: Fri, 5 Jun 2015 16:14:19 +0200 Message-Id: <1433513661-7267-5-git-send-email-kraxel@redhat.com> In-Reply-To: <1433513661-7267-1-git-send-email-kraxel@redhat.com> References: <1433513661-7267-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PULL 4/6] fw_cfg: prohibit insertion of duplicate fw_cfg file names List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Gabriel L. Somlo" , Gerd Hoffmann From: "Gabriel L. Somlo" Exit with an error (instead of simply logging a trace event) whenever the same fw_cfg file name is added multiple times via one of the fw_cfg_add_file[_callback]() host-side API calls. Signed-off-by: Gabriel Somlo Reviewed-by: Laszlo Ersek Signed-off-by: Gerd Hoffmann --- hw/nvram/fw_cfg.c | 11 ++++++----- trace-events | 1 - 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 227beaf..8d4ea25 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -505,18 +505,19 @@ void fw_cfg_add_file_callback(FWCfgState *s, const char *filename, index = be32_to_cpu(s->files->count); assert(index < FW_CFG_FILE_SLOTS); - fw_cfg_add_bytes_read_callback(s, FW_CFG_FILE_FIRST + index, - callback, callback_opaque, data, len); - pstrcpy(s->files->f[index].name, sizeof(s->files->f[index].name), filename); for (i = 0; i < index; i++) { if (strcmp(s->files->f[index].name, s->files->f[i].name) == 0) { - trace_fw_cfg_add_file_dupe(s, s->files->f[index].name); - return; + error_report("duplicate fw_cfg file name: %s", + s->files->f[index].name); + exit(1); } } + fw_cfg_add_bytes_read_callback(s, FW_CFG_FILE_FIRST + index, + callback, callback_opaque, data, len); + s->files->f[index].size = cpu_to_be32(len); s->files->f[index].select = cpu_to_be16(FW_CFG_FILE_FIRST + index); trace_fw_cfg_add_file(s, index, s->files->f[index].name, len); diff --git a/trace-events b/trace-events index 27d4ba7..9a29df7 100644 --- a/trace-events +++ b/trace-events @@ -195,7 +195,6 @@ ecc_diag_mem_readb(uint64_t addr, uint32_t ret) "Read diagnostic %"PRId64"= %02x # hw/nvram/fw_cfg.c fw_cfg_select(void *s, uint16_t key, int ret) "%p key %d = %d" fw_cfg_read(void *s, uint8_t ret) "%p = %d" -fw_cfg_add_file_dupe(void *s, char *name) "%p %s" fw_cfg_add_file(void *s, int index, char *name, size_t len) "%p #%d: %s (%zd bytes)" # hw/block/hd-geometry.c -- 1.8.3.1