From b8dfacba88aa811dba6f87bb33af32147375dae6 Mon Sep 17 00:00:00 2001 From: Bartosz Kokoszko Date: Thu, 25 Oct 2018 12:59:51 +0200 Subject: [PATCH] logger: refinement handling invalid trace address In case of getting invalid trace address file descriptor now moves forward only one dword, not whole struct dma_log as it was earlier. Signed-off-by: Bartosz Kokoszko --- rmbox/logger_convert.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/rmbox/logger_convert.c b/rmbox/logger_convert.c index e54f3d5..f2adab9 100644 --- a/rmbox/logger_convert.c +++ b/rmbox/logger_convert.c @@ -282,10 +282,17 @@ static int logger_read(struct convert_config *config, return -ferror(config->in_fd); } - /* checking log address */ + /* checking if received trace address is located in + * entry section in elf file. + */ if ((dma_log.address < snd->base_address) || - dma_log.address > snd->base_address + snd->data_length) + dma_log.address > snd->base_address + snd->data_length) { + /* in case the address is not correct input fd should be + * move forward by one DWORD, not entire struct dma_log + */ + fseek(config->in_fd, -(sizeof(dma_log) - sizeof(uint32_t)), SEEK_CUR); continue; + } /* fetching entry from elf dump */ ret = fetch_entry(config, snd->base_address, snd->data_offset,