From 9e91a352064f48e0b806096988e03f6f4ebd35a0 Mon Sep 17 00:00:00 2001 From: Michael Snyder Date: Tue, 1 Mar 2011 01:58:33 +0000 Subject: [PATCH] 2011-02-28 Michael Snyder * coffread.c (coff_getfilename): Add check to avoid overflow. --- gdb/ChangeLog | 2 ++ gdb/coffread.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b1b8bf9d0a4..557f89f1ff1 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,7 @@ 2011-02-28 Michael Snyder + * coffread.c (coff_getfilename): Add check to avoid overflow. + * objc-lang.c (selectors_info): Add a small safety margin to avoid overflow. (classes_info): Error out on too long REGEXP. diff --git a/gdb/coffread.c b/gdb/coffread.c index 156661128e2..9df775d46b9 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1316,7 +1316,11 @@ coff_getfilename (union internal_auxent *aux_entry) char *result; if (aux_entry->x_file.x_n.x_zeroes == 0) - strcpy (buffer, stringtab + aux_entry->x_file.x_n.x_offset); + { + if (strlen (stringtab + aux_entry->x_file.x_n.x_offset) >= BUFSIZ) + internal_error (__FILE__, __LINE__, _("coff file name too long")); + strcpy (buffer, stringtab + aux_entry->x_file.x_n.x_offset); + } else { strncpy (buffer, aux_entry->x_file.x_fname, FILNMLEN); -- 2.30.2