qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] elf2dmp: fixes of code analysis warnings
@ 2023-09-30 23:53 Viktor Prutyanov
  2023-09-30 23:53 ` [PATCH v2 1/2] elf2dmp: limit print length for sign_rsds Viktor Prutyanov
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Viktor Prutyanov @ 2023-09-30 23:53 UTC (permalink / raw)
  To: peter.maydell; +Cc: qemu-devel, akihiko.odaki, yan, viktor, viktor.prutyanov

This series tries to fix Coverity warnings.

v2: fix commit authorship, add CIDs

Viktor Prutyanov (2):
  elf2dmp: limit print length for sign_rsds
  elf2dmp: check array bounds in pdb_get_file_size

 contrib/elf2dmp/main.c |  2 +-
 contrib/elf2dmp/pdb.c  | 13 +++++++++----
 2 files changed, 10 insertions(+), 5 deletions(-)

-- 
2.21.0



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/2] elf2dmp: limit print length for sign_rsds
  2023-09-30 23:53 [PATCH v2 0/2] elf2dmp: fixes of code analysis warnings Viktor Prutyanov
@ 2023-09-30 23:53 ` Viktor Prutyanov
  2023-09-30 23:53 ` [PATCH v2 2/2] elf2dmp: check array bounds in pdb_get_file_size Viktor Prutyanov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Viktor Prutyanov @ 2023-09-30 23:53 UTC (permalink / raw)
  To: peter.maydell; +Cc: qemu-devel, akihiko.odaki, yan, viktor, viktor.prutyanov

String sign_rsds isn't terminated, so the print length must be limited.

Fixes: Coverity CID 1521598
Signed-off-by: Viktor Prutyanov <viktor@daynix.com>
---
 contrib/elf2dmp/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c
index 5db163bdbe..6de5c9808e 100644
--- a/contrib/elf2dmp/main.c
+++ b/contrib/elf2dmp/main.c
@@ -478,7 +478,7 @@ static bool pe_check_pdb_name(uint64_t base, void *start_addr,
     }
 
     if (memcmp(&rsds->Signature, sign_rsds, sizeof(sign_rsds))) {
-        eprintf("CodeView signature is \'%.4s\', \'%s\' expected\n",
+        eprintf("CodeView signature is \'%.4s\', \'%.4s\' expected\n",
                 rsds->Signature, sign_rsds);
         return false;
     }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] elf2dmp: check array bounds in pdb_get_file_size
  2023-09-30 23:53 [PATCH v2 0/2] elf2dmp: fixes of code analysis warnings Viktor Prutyanov
  2023-09-30 23:53 ` [PATCH v2 1/2] elf2dmp: limit print length for sign_rsds Viktor Prutyanov
@ 2023-09-30 23:53 ` Viktor Prutyanov
  2023-10-02  6:35   ` Philippe Mathieu-Daudé
  2023-10-05  5:20 ` [PATCH v2 0/2] elf2dmp: fixes of code analysis warnings Akihiko Odaki
  2023-10-16 16:35 ` Peter Maydell
  3 siblings, 1 reply; 6+ messages in thread
From: Viktor Prutyanov @ 2023-09-30 23:53 UTC (permalink / raw)
  To: peter.maydell; +Cc: qemu-devel, akihiko.odaki, yan, viktor, viktor.prutyanov

Index in file_size array must be checked against num_files, because the
entries we are looking for may be absent in the PDB.

Fixes: Coverity CID 1521597
Signed-off-by: Viktor Prutyanov <viktor@daynix.com>
---
 contrib/elf2dmp/pdb.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c
index 6ca5086f02..8e3c18c82f 100644
--- a/contrib/elf2dmp/pdb.c
+++ b/contrib/elf2dmp/pdb.c
@@ -25,6 +25,10 @@
 
 static uint32_t pdb_get_file_size(const struct pdb_reader *r, unsigned idx)
 {
+    if (idx >= r->ds.toc->num_files) {
+        return 0;
+    }
+
     return r->ds.toc->file_size[idx];
 }
 
@@ -159,16 +163,17 @@ static void *pdb_ds_read_file(struct pdb_reader* r, uint32_t file_number)
 
 static int pdb_init_segments(struct pdb_reader *r)
 {
-    char *segs;
     unsigned stream_idx = r->segments;
 
-    segs = pdb_ds_read_file(r, stream_idx);
-    if (!segs) {
+    r->segs = pdb_ds_read_file(r, stream_idx);
+    if (!r->segs) {
         return 1;
     }
 
-    r->segs = segs;
     r->segs_size = pdb_get_file_size(r, stream_idx);
+    if (!r->segs_size) {
+        return 1;
+    }
 
     return 0;
 }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] elf2dmp: check array bounds in pdb_get_file_size
  2023-09-30 23:53 ` [PATCH v2 2/2] elf2dmp: check array bounds in pdb_get_file_size Viktor Prutyanov
@ 2023-10-02  6:35   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-02  6:35 UTC (permalink / raw)
  To: Viktor Prutyanov, peter.maydell
  Cc: qemu-devel, akihiko.odaki, yan, viktor.prutyanov

On 1/10/23 01:53, Viktor Prutyanov wrote:
> Index in file_size array must be checked against num_files, because the
> entries we are looking for may be absent in the PDB.
> 
> Fixes: Coverity CID 1521597
> Signed-off-by: Viktor Prutyanov <viktor@daynix.com>
> ---
>   contrib/elf2dmp/pdb.c | 13 +++++++++----
>   1 file changed, 9 insertions(+), 4 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/2] elf2dmp: fixes of code analysis warnings
  2023-09-30 23:53 [PATCH v2 0/2] elf2dmp: fixes of code analysis warnings Viktor Prutyanov
  2023-09-30 23:53 ` [PATCH v2 1/2] elf2dmp: limit print length for sign_rsds Viktor Prutyanov
  2023-09-30 23:53 ` [PATCH v2 2/2] elf2dmp: check array bounds in pdb_get_file_size Viktor Prutyanov
@ 2023-10-05  5:20 ` Akihiko Odaki
  2023-10-16 16:35 ` Peter Maydell
  3 siblings, 0 replies; 6+ messages in thread
From: Akihiko Odaki @ 2023-10-05  5:20 UTC (permalink / raw)
  To: Viktor Prutyanov, peter.maydell; +Cc: qemu-devel, yan, viktor.prutyanov

On 2023/10/01 8:53, Viktor Prutyanov wrote:
> This series tries to fix Coverity warnings.
> 
> v2: fix commit authorship, add CIDs
> 
> Viktor Prutyanov (2):
>    elf2dmp: limit print length for sign_rsds
>    elf2dmp: check array bounds in pdb_get_file_size
> 
>   contrib/elf2dmp/main.c |  2 +-
>   contrib/elf2dmp/pdb.c  | 13 +++++++++----
>   2 files changed, 10 insertions(+), 5 deletions(-)
> 

For the whole series,
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/2] elf2dmp: fixes of code analysis warnings
  2023-09-30 23:53 [PATCH v2 0/2] elf2dmp: fixes of code analysis warnings Viktor Prutyanov
                   ` (2 preceding siblings ...)
  2023-10-05  5:20 ` [PATCH v2 0/2] elf2dmp: fixes of code analysis warnings Akihiko Odaki
@ 2023-10-16 16:35 ` Peter Maydell
  3 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2023-10-16 16:35 UTC (permalink / raw)
  To: Viktor Prutyanov; +Cc: qemu-devel, akihiko.odaki, yan, viktor.prutyanov

On Sun, 1 Oct 2023 at 00:53, Viktor Prutyanov <viktor@daynix.com> wrote:
>
> This series tries to fix Coverity warnings.
>
> v2: fix commit authorship, add CIDs

Applied to target-arm.next (since I took the last set of
elf2dmp patches), thanks.

-- PMM


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-10-16 16:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-30 23:53 [PATCH v2 0/2] elf2dmp: fixes of code analysis warnings Viktor Prutyanov
2023-09-30 23:53 ` [PATCH v2 1/2] elf2dmp: limit print length for sign_rsds Viktor Prutyanov
2023-09-30 23:53 ` [PATCH v2 2/2] elf2dmp: check array bounds in pdb_get_file_size Viktor Prutyanov
2023-10-02  6:35   ` Philippe Mathieu-Daudé
2023-10-05  5:20 ` [PATCH v2 0/2] elf2dmp: fixes of code analysis warnings Akihiko Odaki
2023-10-16 16:35 ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).