summaryrefslogtreecommitdiff
path: root/gdb/procfs.c
diff options
context:
space:
mode:
authormeyering <meyering>2012-04-25 08:16:35 +0000
committermeyering <meyering>2012-04-25 08:16:35 +0000
commitee924b7b0a4475da0a90eceeddb993cf44720e24 (patch)
tree65a546242ca69692e771160570ba25ec611e202a /gdb/procfs.c
parenta4fd2acbd17a25cfddf394f8fdbdef53397a836e (diff)
downloadgdb-ee924b7b0a4475da0a90eceeddb993cf44720e24.tar.gz
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.
Diffstat (limited to 'gdb/procfs.c')
-rw-r--r--gdb/procfs.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/gdb/procfs.c b/gdb/procfs.c
index cb4bc7c626c..d7c2946bffc 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -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 &&