[commit] printcmd.c, print_scalar_formatted, use strncpy.
Pedro Alves
pedro@codesourcery.com
Wed Mar 2 23:42:00 GMT 2011
On Wednesday 02 March 2011 23:00:23, Michael Snyder wrote:
> strncpy2.txt
> 2011-03-02 Michael Snyder <msnyder@vmware.com>
>
> * printcmd.c (print_scalar_formatted): Use strncpy for safety.
>
> Index: printcmd.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/printcmd.c,v
> retrieving revision 1.192
> diff -u -p -u -p -r1.192 printcmd.c
> --- printcmd.c 26 Feb 2011 02:07:08 -0000 1.192
> +++ printcmd.c 2 Mar 2011 22:55:38 -0000
> @@ -533,7 +533,7 @@ print_scalar_formatted (const void *vala
> if (*cp == '\0')
> cp--;
> }
> - strcpy (buf, cp);
> + strncpy (buf, cp, sizeof (bits));
> fputs_filtered (buf, stream);
> }
> break;
We've been through this recently... This is not safe.
--
Pedro Alves
More information about the Gdb-patches
mailing list