x86/disasm: do not use format string without format specifiers

Message ID 20260523111759.1294571-1-hawkinsw@obs.cr
State New
Headers
Series x86/disasm: do not use format string without format specifiers |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

Will Hawkins May 23, 2026, 11:17 a.m. UTC
  Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
---
 opcodes/i386-dis.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Comments

H.J. Lu May 24, 2026, 2:51 a.m. UTC | #1
On Sat, May 23, 2026 at 7:18 PM Will Hawkins <hawkinsw@obs.cr> wrote:

Please mention this fixes PR binutils/34168 with -Werror=format-security:

https://sourceware.org/bugzilla/show_bug.cgi?id=34168

> Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
> ---
>  opcodes/i386-dis.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
> index 1faf1fa7785..db1e4f7a7d5 100644
> --- a/opcodes/i386-dis.c
> +++ b/opcodes/i386-dis.c
> @@ -10375,7 +10375,7 @@ print_insn (bfd_vma pc, disassemble_info *info, int intel_syntax)
>    for (i = 0; i < MAX_OPERANDS; i++)
>      if (ins.op_index[i] != -1 && ins.op_riprel[i])
>        {
> -       i386_dis_printf (info, dis_style_comment_start, sep);
> +       i386_dis_printf (info, dis_style_comment_start, "%s", sep);
>         sep = ", ";
>         (*info->print_address_func)
>           ((bfd_vma)(ins.start_pc + (ins.codep - ins.start_codep)
> @@ -10384,11 +10384,11 @@ print_insn (bfd_vma pc, disassemble_info *info, int intel_syntax)
>        }
>      else if (*ins.cm_out[i])
>        {
> -       i386_dis_printf (info, dis_style_comment_start, sep);
> +       i386_dis_printf (info, dis_style_comment_start, "%s", sep);
>         sep = ", ";
>         i386_dis_printf (info, dis_style_symbol, "%s", ins.cm_out[i]);
>        }
> -
> +

I pushed a separate commit to remove trailing spaces:

commit c5590002d8ee23c8ee3d64803e4e03c5992903c1
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sun May 24 10:45:37 2026 +0800

    i386-dis.c: Remove trailing spaces

            * i386-dis.c (print_insn): Remove trailing spaces.

>    ret = ins.codep - priv.the_buffer;
>   out:
>    info->private_data = NULL;
> --
> 2.49.0
>
  
Will Hawkins May 24, 2026, 2:52 a.m. UTC | #2
On Sat, May 23, 2026 at 10:51 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Sat, May 23, 2026 at 7:18 PM Will Hawkins <hawkinsw@obs.cr> wrote:
>
> Please mention this fixes PR binutils/34168 with -Werror=format-security:
>
> https://sourceware.org/bugzilla/show_bug.cgi?id=34168

Will do!! I just wanted to let you know that I tried to help!

Will

>
> > Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
> > ---
> >  opcodes/i386-dis.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
> > index 1faf1fa7785..db1e4f7a7d5 100644
> > --- a/opcodes/i386-dis.c
> > +++ b/opcodes/i386-dis.c
> > @@ -10375,7 +10375,7 @@ print_insn (bfd_vma pc, disassemble_info *info, int intel_syntax)
> >    for (i = 0; i < MAX_OPERANDS; i++)
> >      if (ins.op_index[i] != -1 && ins.op_riprel[i])
> >        {
> > -       i386_dis_printf (info, dis_style_comment_start, sep);
> > +       i386_dis_printf (info, dis_style_comment_start, "%s", sep);
> >         sep = ", ";
> >         (*info->print_address_func)
> >           ((bfd_vma)(ins.start_pc + (ins.codep - ins.start_codep)
> > @@ -10384,11 +10384,11 @@ print_insn (bfd_vma pc, disassemble_info *info, int intel_syntax)
> >        }
> >      else if (*ins.cm_out[i])
> >        {
> > -       i386_dis_printf (info, dis_style_comment_start, sep);
> > +       i386_dis_printf (info, dis_style_comment_start, "%s", sep);
> >         sep = ", ";
> >         i386_dis_printf (info, dis_style_symbol, "%s", ins.cm_out[i]);
> >        }
> > -
> > +
>
> I pushed a separate commit to remove trailing spaces:
>
> commit c5590002d8ee23c8ee3d64803e4e03c5992903c1
> Author: H.J. Lu <hjl.tools@gmail.com>
> Date:   Sun May 24 10:45:37 2026 +0800
>
>     i386-dis.c: Remove trailing spaces
>
>             * i386-dis.c (print_insn): Remove trailing spaces.
>
> >    ret = ins.codep - priv.the_buffer;
> >   out:
> >    info->private_data = NULL;
> > --
> > 2.49.0
> >
>
>
> --
> H.J.
  
H.J. Lu May 24, 2026, 2:53 a.m. UTC | #3
On Sun, May 24, 2026 at 10:52 AM Will Hawkins <hawkinsw@obs.cr> wrote:
>
> On Sat, May 23, 2026 at 10:51 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > On Sat, May 23, 2026 at 7:18 PM Will Hawkins <hawkinsw@obs.cr> wrote:
> >
> > Please mention this fixes PR binutils/34168 with -Werror=format-security:
> >
> > https://sourceware.org/bugzilla/show_bug.cgi?id=34168
>
> Will do!! I just wanted to let you know that I tried to help!

Thanks.  Appreciate it.

> Will
>
> >
> > > Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
> > > ---
> > >  opcodes/i386-dis.c | 6 +++---
> > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
> > > index 1faf1fa7785..db1e4f7a7d5 100644
> > > --- a/opcodes/i386-dis.c
> > > +++ b/opcodes/i386-dis.c
> > > @@ -10375,7 +10375,7 @@ print_insn (bfd_vma pc, disassemble_info *info, int intel_syntax)
> > >    for (i = 0; i < MAX_OPERANDS; i++)
> > >      if (ins.op_index[i] != -1 && ins.op_riprel[i])
> > >        {
> > > -       i386_dis_printf (info, dis_style_comment_start, sep);
> > > +       i386_dis_printf (info, dis_style_comment_start, "%s", sep);
> > >         sep = ", ";
> > >         (*info->print_address_func)
> > >           ((bfd_vma)(ins.start_pc + (ins.codep - ins.start_codep)
> > > @@ -10384,11 +10384,11 @@ print_insn (bfd_vma pc, disassemble_info *info, int intel_syntax)
> > >        }
> > >      else if (*ins.cm_out[i])
> > >        {
> > > -       i386_dis_printf (info, dis_style_comment_start, sep);
> > > +       i386_dis_printf (info, dis_style_comment_start, "%s", sep);
> > >         sep = ", ";
> > >         i386_dis_printf (info, dis_style_symbol, "%s", ins.cm_out[i]);
> > >        }
> > > -
> > > +
> >
> > I pushed a separate commit to remove trailing spaces:
> >
> > commit c5590002d8ee23c8ee3d64803e4e03c5992903c1
> > Author: H.J. Lu <hjl.tools@gmail.com>
> > Date:   Sun May 24 10:45:37 2026 +0800
> >
> >     i386-dis.c: Remove trailing spaces
> >
> >             * i386-dis.c (print_insn): Remove trailing spaces.
> >
> > >    ret = ins.codep - priv.the_buffer;
> > >   out:
> > >    info->private_data = NULL;
> > > --
> > > 2.49.0
> > >
> >
> >
> > --
> > H.J.
  

Patch

diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
index 1faf1fa7785..db1e4f7a7d5 100644
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -10375,7 +10375,7 @@  print_insn (bfd_vma pc, disassemble_info *info, int intel_syntax)
   for (i = 0; i < MAX_OPERANDS; i++)
     if (ins.op_index[i] != -1 && ins.op_riprel[i])
       {
-	i386_dis_printf (info, dis_style_comment_start, sep);
+	i386_dis_printf (info, dis_style_comment_start, "%s", sep);
 	sep = ", ";
 	(*info->print_address_func)
 	  ((bfd_vma)(ins.start_pc + (ins.codep - ins.start_codep)
@@ -10384,11 +10384,11 @@  print_insn (bfd_vma pc, disassemble_info *info, int intel_syntax)
       }
     else if (*ins.cm_out[i])
       {
-	i386_dis_printf (info, dis_style_comment_start, sep);
+	i386_dis_printf (info, dis_style_comment_start, "%s", sep);
 	sep = ", ";
 	i386_dis_printf (info, dis_style_symbol, "%s", ins.cm_out[i]);
       }
-  
+
   ret = ins.codep - priv.the_buffer;
  out:
   info->private_data = NULL;