From 3d4a522e2556c6484f64331af24664ed5e8aa2a3 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Tue, 17 Sep 2013 13:57:21 +0000 Subject: [PATCH] PR ld/15957 * deffilep.y (def_file_add_directive): Avoid readin past end of buffer. --- ld/ChangeLog | 6 ++++++ ld/deffilep.y | 19 +++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 1ae8a118e6e..bc3e8da56ba 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,9 @@ +2013-09-17 Nick Clifton + + PR ld/15957 + * deffilep.y (def_file_add_directive): Avoid readin past end of + buffer. + 2013-08-28 Nick Clifton PR ld/15896 diff --git a/ld/deffilep.y b/ld/deffilep.y index 9121f8f59c3..2dd21be8bb6 100644 --- a/ld/deffilep.y +++ b/ld/deffilep.y @@ -934,13 +934,20 @@ def_file_add_directive (def_file *my_def, const char *param, int len) if (!diropts[i].param) { - char saved; + if (tend < pend) + { + char saved; - saved = * tend; - * tend = 0; - /* xgettext:c-format */ - einfo (_("Warning: .drectve `%s' unrecognized\n"), param); - * tend = saved; + saved = * tend; + * tend = 0; + /* xgettext:c-format */ + einfo (_("Warning: .drectve `%s' unrecognized\n"), param); + * tend = saved; + } + else + { + einfo (_("Warning: corrupt .drectve at end of def file\n")); + } } lex_parse_string = 0; -- 2.30.2