diff options
author | Jim Meyering <meyering@sourceware.org> | 2012-04-25 08:16:43 +0000 |
---|---|---|
committer | Jim Meyering <meyering@sourceware.org> | 2012-04-25 08:16:43 +0000 |
commit | 4e2af517f12dc3ac61278947995bc8918069a297 (patch) | |
tree | 1b04aab71477ae53eff86c751d605f821230fa1c /gdb/procfs.c | |
parent | b77b7f52b886b60cfc13858d1d3f0b8e8d702147 (diff) | |
download | gdb-4e2af517f12dc3ac61278947995bc8918069a297.zip gdb-4e2af517f12dc3ac61278947995bc8918069a297.tar.gz gdb-4e2af517f12dc3ac61278947995bc8918069a297.tar.bz2 |
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.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/gdb/procfs.c b/gdb/procfs.c index cb4bc7c..d7c2946 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 && |