avoid a few strncpy-induced buffer overruns

* procfs.c (procfs_make_note_section): Be sure to NUL-terminate
fname and psargs before trying to concatenate.
* tui/tui-stack.c (tui_get_function_from_frame): NUL-terminate
"name" before applying strchr.
This commit is contained in:
Jim Meyering
2012-04-25 08:16:43 +00:00
parent b77b7f52b8
commit 4e2af517f1
3 changed files with 12 additions and 2 deletions

View File

@@ -5725,8 +5725,9 @@ procfs_make_note_section (bfd *obfd, int *note_size)
if (get_exec_file (0))
{
strncpy (fname, lbasename (get_exec_file (0)), sizeof (fname));
strncpy (psargs, get_exec_file (0),
sizeof (psargs));
fname[sizeof (fname) - 1] = 0;
strncpy (psargs, get_exec_file (0), sizeof (psargs));
psargs[sizeof (psargs) - 1] = 0;
inf_args = get_inferior_args ();
if (inf_args && *inf_args &&