public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] asan: csky floatformat_to_double uninitialised value
@ 2023-04-03 13:45 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2023-04-03 13:45 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5cdf86d363747a5e0b67165d32ab512ff50d83d2

commit 5cdf86d363747a5e0b67165d32ab512ff50d83d2
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Apr 3 12:35:53 2023 +0930

    asan: csky floatformat_to_double uninitialised value
    
            * csky-dis.c (csky_print_operand <OPRND_TYPE_FCONSTANT>): Don't
            access ibytes after read_memory_func error.  Change type of
            ibytes to avoid casts.

Diff:
---
 opcodes/csky-dis.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/opcodes/csky-dis.c b/opcodes/csky-dis.c
index fc7d595ccec..1deea049d7e 100644
--- a/opcodes/csky-dis.c
+++ b/opcodes/csky-dis.c
@@ -519,7 +519,7 @@ csky_output_operand (char *str, struct operand const *oprnd,
     case OPRND_TYPE_FCONSTANT:
       {
 	int shift = oprnd->shift;
-	char ibytes[8];
+	bfd_byte ibytes[8];
 	int status;
 	bfd_vma addr;
 	int nbytes;
@@ -538,19 +538,13 @@ csky_output_operand (char *str, struct operand const *oprnd,
 	else
 	  nbytes = 4;
 
-	status = dis_info.info->read_memory_func (addr, (bfd_byte *)ibytes,
+	status = dis_info.info->read_memory_func (addr, ibytes,
 						  nbytes, dis_info.info);
 	if (status != 0)
 	  /* Address out of bounds.  -> lrw rx, [pc, 0ffset]. */
 	  sprintf (buf, "[pc, %d]\t// from address pool at %x", (int)value,
 		   (unsigned int)addr);
-	else
-	  {
-	    dis_info.value = addr;
-	    value = csky_chars_to_number ((unsigned char *)ibytes, 4);
-	  }
-
-	if (oprnd->type == OPRND_TYPE_FCONSTANT)
+	else if (oprnd->type == OPRND_TYPE_FCONSTANT)
 	  {
 	    double f;
 
@@ -569,8 +563,10 @@ csky_output_operand (char *str, struct operand const *oprnd,
 	  }
 	else
 	  {
+	    dis_info.value = addr;
 	    dis_info.need_output_symbol = 1;
-	    sprintf (buf, "0x%x", (unsigned int)value);
+	    value = csky_chars_to_number (ibytes, 4);
+	    sprintf (buf, "0x%x", (unsigned int) value);
 	  }
 
 	strcat (str, buf);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-03 13:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-03 13:45 [binutils-gdb] asan: csky floatformat_to_double uninitialised value Alan Modra

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 read-only IMAP folder(s) and NNTP newsgroup(s).