* or32-opc.c (or32_print_register, or32_print_immediate,
authorNick Clifton <nickc@redhat.com>
Fri, 2 Jan 2009 14:21:54 +0000 (14:21 +0000)
committerNick Clifton <nickc@redhat.com>
Fri, 2 Jan 2009 14:21:54 +0000 (14:21 +0000)
        disassemble_insn): Don't rely on undefined sprintf behaviour.

        * itbl-ops.c (itbl_disassemble): Don't rely on undefined sprintf
        behaviour.

gas/ChangeLog
gas/itbl-ops.c
opcodes/ChangeLog
opcodes/or32-opc.c

index e9fa29843037bd4c6a130ee0491835a29d748cc4..41ddb7d39354cf174037a316d6e265b549afb37d 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-02  Matthias Klose  <doko@ubuntu.com> 
+        * itbl-ops.c (itbl_disassemble): Don't rely on undefined sprintf 
+        behaviour. 
+
 2008-12-23  Jon Beniston <jon@beniston.com>
 
        * NEWS: Record that support for LM32 has been added.
index 948ec99672cfb7596799bda17d9198b98f3caa03..e2f39d1b252ae54c8c438bb58cd8c113feab84ef 100644 (file)
@@ -1,6 +1,6 @@
 /* itbl-ops.c
-   Copyright 1997, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007
-   Free Software Foundation, Inc.
+   Copyright 1997, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007,
+   2009  Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
@@ -593,6 +593,7 @@ itbl_disassemble (char *s, unsigned long insn)
     {
       struct itbl_entry *r;
       unsigned long value;
+      char s_value[20];
 
       if (f == e->fields)      /* First operand is preceded by tab.  */
        strcat (s, "\t");
@@ -611,14 +612,18 @@ itbl_disassemble (char *s, unsigned long insn)
          if (r)
            strcat (s, r->name);
          else
-           sprintf (s, "%s$%lu", s, value);
+           {
+             sprintf (s_value, "$%lu", value);
+             strcat (s, s_value);
+           }
          break;
        case e_addr:
          /* Use assembler's symbol table to find symbol.  */
          /* FIXME!! Do we need this?  If so, what about relocs??  */
          /* If not a symbol, fall through to IMMED.  */
        case e_immed:
-         sprintf (s, "%s0x%lx", s, value);
+         sprintf (s_value, "0x%lx", value);
+         strcat (s, s_value);
          break;
        default:
          return 0;             /* error; invalid field spec */
index 4b4f7ba6424255560d4edb570e5772b2857ed21e..c6c6d6b799e1ee40cdb60ceb6b4936a97b09426e 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-02  Matthias Klose  <doko@ubuntu.com> 
+        * or32-opc.c (or32_print_register, or32_print_immediate, 
+        disassemble_insn): Don't rely on undefined sprintf behaviour. 
+
 2008-12-30  Martin Schwidefsky  <schwidefskyy@de.ibm.com>
 
        * s390-opc.txt: Add ptff instruction.
index aa94c1365ce666fdbf8f08c8247857ab48642779..24ab5cf28093bba197ef618f937a25006346661a 100644 (file)
@@ -1,5 +1,5 @@
 /* Table of opcodes for the OpenRISC 1000 ISA.
-   Copyright 2002, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+   Copyright 2002, 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
    Contributed by Damjan Lampret (lampret@opencores.org).
    
    This file is part of the GNU opcodes library.
@@ -951,8 +951,10 @@ static void
 or32_print_register (char param_ch, char *encoding, unsigned long insn)
 {
   int regnum = or32_extract(param_ch, encoding, insn);
-  
-  sprintf (disassembled, "%sr%d", disassembled, regnum);
+  char s_regnum[20];
+
+  sprintf (s_regnum, "r%d", regnum);
+  strcat (disassembled, s_regnum);
 }
 
 /* Print immediate. Used only by print_insn.  */
@@ -961,18 +963,20 @@ static void
 or32_print_immediate (char param_ch, char *encoding, unsigned long insn)
 {
   int imm = or32_extract (param_ch, encoding, insn);
+  char s_imm[20];
 
   imm = extend_imm (imm, param_ch);
-  
+
   if (letter_signed (param_ch))
     {
       if (imm < 0)
-        sprintf (disassembled, "%s%d", disassembled, imm);
+       sprintf (s_imm, "%d", imm);
       else
-        sprintf (disassembled, "%s0x%x", disassembled, imm);
+       sprintf (s_imm, "0x%x", imm);
     }
   else
-    sprintf (disassembled, "%s%#x", disassembled, imm);
+    sprintf (s_imm, "%#x", imm);
+  strcat (disassembled, s_imm);
 }
 
 /* Disassemble one instruction from insn to disassemble.
@@ -1005,14 +1009,22 @@ disassemble_insn (unsigned long insn)
               if (strchr (opcode->encoding, *s))
                 or32_print_immediate (*s, opcode->encoding, insn);
               else
-                sprintf (disassembled, "%s%c", disassembled, *s);
+               {
+                 char s_encoding[2] = { *s, '\0' };
+
+                 strcat (disassembled, s_encoding);
+               }
+
             }
         }
     }
   else
     {
+      char s_insn[20];
+
       /* This used to be %8x for binutils.  */
-      sprintf (disassembled, "%s.word 0x%08lx", disassembled, insn);
+      sprintf (s_insn, ".word 0x%08lx", insn);
+      strcat (disassembled, s_insn);
     }
 
   return insn_len (insn);
This page took 0.028165 seconds and 4 git commands to generate.